MATLAB Examples

# Estimate Parameters of a Three-Parameter Weibull Distribution

This example shows how to estimate parameters of a three-parameter Weibull distribution by using a custom probability density function.

Statistics and Machine Learning Toolbox™ uses a two-parameter Weibull distribution with a shape parameter and a scale parameter . The Weibull distribution can take one more parameter, a location parameter . The probability density function becomes

where and are positive values, and is a real value.

Generate sample data of size 1000 from a three-parameter Weibull distribution with the shape parameter 1, scale parameter 1, and location parameter 10.

rng('default') % For reproducibility
data = wblrnd(1,1,[1000,1])+10;

Define a probability density function for a three-parameter Weibull distribution.

custpdf = @(x,a,b,c) (x>c).*(b/a).*(((x-c)/a).^(b-1)).*exp(-((x-c)/a).^b);

The Weibull probability density function is positive only for . This constraint also implies that a location parameter is smaller than the minimum of the sample data. Include the lower and upper bounds of parameters by using the name-value pair arguments 'LowerBound' and 'UpperBound', respectively.

opt = statset('MaxIter',1e5,'MaxFunEvals',1e5,'FunValCheck','off');
phat = mle(data,'pdf',custpdf,'start',[5 5 5],'Options',opt,...
'LowerBound',[0 0 -Inf],'UpperBound',[Inf Inf min(data)])
phat =

1.0258    1.0618   10.0004

If mle does not converge with default statistics options, you can modify them by using the name-value pair argument 'Options'. Create a statistics options structure opt by using the function statset. Then use opt as the value of 'Options'.

The option opt includes the following:

• 'MaxIter',1e5 — Increase the maximum number of iterations to 1e5.
• 'MaxFunEvals',1e5 — Increase the maximum number of object function evaluations to 1e5.
• 'FunValCheck','off' — Turn off checking for invalid object function values.

For a distribution with a region that has zero probability density, mle might try some parameters that have zero density, and it will fail to estimate parameters. To avoid this problem, you can turn off the option that checks for invalid function values by using 'FunValCheck','off'.

If the scale parameter is smaller than 1, the probability density of the Weibull distribution approaches infinity as goes to , where is the location parameter. The maximum of the likelihood function is infinite. mle may find satisfactory estimates in some cases, but the global maximum is degenerate when .