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.
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)); plot(t,h1,'--',t,h2,'-')
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.
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
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
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
opt includes the following:
'MaxIter',1e5 — Increase the maximum number of iterations to
'MaxFunEvals',1e5 — Increase the maximum number of object function evaluations to
'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
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 .