Weibull Distribution


The Weibull pdf is positive only for positive values of x, and is zero otherwise. For strictly positive values of the shape parameter b and scale parameter a, the density is



Waloddi Weibull offered the distribution that bears his name as an appropriate analytical tool for modeling the breaking strength of materials. Current usage also includes reliability and lifetime modeling. The Weibull distribution is more flexible than the exponential for these purposes.

To see why, consider the hazard rate function (instantaneous failure rate). If f(t) and F(t) are the pdf and cdf of a distribution, then the hazard rate is


Substituting the pdf and cdf of the exponential distribution for f(t) and F(t) above yields a constant. The example below shows that the hazard rate for the Weibull distribution can vary.

Plot the Weibull Distribution Hazard Function

The exponential distribution has a constant hazard function, which is not generally the case for the Weibull distribution. The plot shows the hazard function for exponential (dashed line) and Weibull (solid line) distributions having the same mean life. The Weibull hazard rate here increases with age (a reasonable assumption).

t = 0:0.1:4.5;
h1 = exppdf(t,0.8862)./(1-expcdf(t,0.8862));
h2 = wblpdf(t,1,2)./(1-wblcdf(t,1,2));

Estimate Parameters of the Weibull Distribution

Suppose you want to model the tensile strength of a thin filament using the Weibull distribution. The function wblfit gives maximum likelihood estimates and confidence intervals for the Weibull parameters.

rng('default');  % For reproducibility
strength = wblrnd(0.5,2,100,1);  % Simulated strengths
[p,ci] = wblfit(strength)
p = 1×2

    0.4768    1.9622

ci = 2×2

    0.4291    1.6821
    0.5298    2.2890

The default 95% confidence interval for each parameter contains the true value.

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 a and a scale parameter b. The Weibull distribution can take one more parameter, a location parameter c. The probability density function becomes

f(x|a,b,c)={ba(x-ca)b-1exp(-(x-ca)b)if x>c,0if xc,

where a and b are positive values, and c 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 x>c. This constraint also implies that a location parameter c 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×3

    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 b is smaller than 1, the probability density of the Weibull distribution approaches infinity as x goes to c, where c 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 b<1.

See Also

Related Examples

More About