# Estimating Parameters of a Custom Distribution

The problem is I can not get estimation of parameters of any custom probability distribution (distributions are not built in Mathematica), here is an example:

First: I entered random numbers of custom distribution (I entered the PDF of Weibull distribution) and I want its parameters to be estimated then I have an infinite loop somewhere, and the program runs for hours on a relatively fast machine, without producing anything..the steps on Mathematica are:

custom[a_, b_] := ProbabilityDistribution[(a/b) ((x/b)^(a - 1)) E^-(x/b)^a, {x, 0, \[Infinity]}]
PDF[custom[a, b]]
W = RandomVariate[custom[2, 3], 50]
FindDistributionParameters[W, custom[a, b]]


Second: I entered the same steps but I replace final step with FindDistributionParameters[W, WeibullDistribution[a, b]]. I got the answer in one second

{a -> 1.99144, b -> 2.6355}


The problem is if the custom distribution is not built in Mathematica what will be happened to estimate its parameters???

• On second thoughts: How does this question differ from your first one: How to estimate parameters of a custom distribution?? Oct 6, 2014 at 14:49
• Dear Yves Keltt the main idea not on mathimatical properties as it was commented before..the main idea on Mathematica coding language..i illustrate my point on this example.
– Momo
Oct 7, 2014 at 6:51
• Dear Momo, I am not entirely sure about the difference between the questions. Hopefully the answer here can help you, otherwise please edit the original one to reflect the differences. Oct 7, 2014 at 9:24

Clear[custom];


When defining the custom distribution, include the parameter assumptions required for the custom distribution to be a valid distribution.

custom[a_, b_] = ProbabilityDistribution[
(a/b) ((x/b)^(a - 1)) E^-(x/b)^a, {x, 0, Infinity},
Assumptions -> a > 0 && b > 0];

DistributionParameterAssumptions[custom[a, b]]


a > 0 && b > 0

W = RandomVariate[custom[2, 3], 50];

FindDistributionParameters[W, custom[a, b]]


{a -> 2.11554, b -> 3.11318}

FindDistributionParameters[W, WeibullDistribution[a, b]]


{a -> 2.11554, b -> 3.11318}

As expected, the parameters are identical since

PDF[custom[a, b], x] == PDF[WeibullDistribution[a, b], x]


True

• it works goo Thanks alot
– Momo
Oct 8, 2014 at 7:44

Estimates of parameters deserve estimates of precision. Unfortunately, FindDistributionParameters doesn't provide that. However, it is relatively easy to do in Mathematica.

(* Generate data *)
SeedRandom[12345];
W = RandomVariate[custom[2, 3], 50];

(* Maximum likelihood estimates of parameters *)
mle = FindDistributionParameters[W, custom[a, b]]
(* {a -> 2.68137, b -> 2.85603} *)

(* Log of the likelihood *)
logL = LogLikelihood[custom[a, b], W];

(* Covariance matrix of parameter estimators *)
cov = -Inverse[D[logL, {{a, b}, 2}] /. mle]
(* {{0.0900731, 0.0148357}, {0.0148357, 0.0251339}} *)

(* Standard errors of estimators of a and b, respectively *)
stdErrs = Sqrt[Diagonal[cov]]
(* {0.300122, 0.158537} *)

(* Correlation between estimators of a and b *)
abCorrelation = cov[[1, 2]]/Sqrt[cov[[1, 1]] cov[[2, 2]]]
(* 0.311804 *)