Main Content

wblfit

Weibull parameter estimates

Description

example

parmHat= wblfit(x)returns the estimates of Weibull distribution parameters (shape and scale), given the sample data inx.

example

[parmHat,parmCI] = wblfit(x)also returns the 95% confidence intervals for the parameter estimates.

[parmHat,parmCI] = wblfit(x,alpha)specifies the confidence level for the confidence intervals to be100(1—alpha)%.

[___] = wblfit(x,alpha,censoring)specifies whether each value inxis right-censored or not. Use the logical vectorcensoringin which 1 indicates observations that are right-censored and 0 indicates observations that are fully observed.

[___] = wblfit(x,alpha,censoring,freq)specifies the frequency or weights of observations.

example

[___] = wblfit(x,alpha,censoring,freq,options)specifies optimization options for the iterative algorithmwblfitto use to compute maximum likelihood estimates (MLEs) with censoring. Createoptionsby using the functionstatset.

You can pass in[]foralpha,censoring, andfreqto use their default values.

Examples

collapse all

Generate 100 random numbers from the Weibull distribution with scale0.8and shape3.

x = wblrnd(0.8,3,100,1);

Estimate the parameters of the Weibull distribution from the data.

parmHat = wblfit(x)
parmHat =1×20.7751 2.9433

Generate 100 random numbers from the Weibull distribution with scale1and shape2.

x = wblrnd(1,2,100,1);

Find the95%confidence intervals estimating the parameters of the Weibull distribution from the data.

[parmHat,parmCI] = wblfit(x)
parmHat =1×20.9536 1.9622
parmCI =2×20.8583 1.6821 1.0596 2.2890

The top row ofparmCIcontains the lower bounds of the confidence intervals and the bottom row contains the upper bounds of the confidence intervals.

Generate 100 Weibull random variables from the distribution with scale2and shape5.

x = wblrnd(2,5,100,1);

Display the algorithm parameters forwblfit.

statset('wblfit')
ans =struct with fields:Display: 'off' MaxFunEvals: [] MaxIter: [] TolBnd: [] TolFun: [] TolTypeFun: [] TolX: 1.0000e-06 TolTypeX: [] GradObj: [] Jacobian: [] DerivStep: [] FunValCheck: [] Robust: [] RobustWgtFun: [] WgtFun: [] Tune: [] UseParallel: [] UseSubstreams: [] Streams: {} OutputFcn: []

Specify algorithm parameters using name-value pair arguments of the functionstatset. Change how results are displayed (Display), and set the termination tolerance for parameters (TolX).

options = statset('Display','iter','TolX',1e-4);% Optimization options

Find the MLEs using the new algorithm parameters.

parmhat = wblfit(x,[],[],[],options)
Func-count x f(x) Procedure 2 0.193283 -0.0172927 initial 3 0.205467 0.00262429 interpolation 4 0.203862 2.99018e-05 interpolation 5 0.203862 2.99018e-05 interpolation Zero found in the interval [0.193283, 0.386565]
parmhat =1×21.9624 4.9050

wblfitdisplays information about the iterations.

Input Arguments

collapse all

Sample data, specified as a vector.

Data Types:single|double

Significance level for the confidence intervals, specified as a scalar in the range (0,1). The confidence level is100(1—alpha)%, wherealphais the probability that the confidence intervals do not contain the true value.

Example:0.01

Data Types:single|double

Indicator for the censoring of each value inx, specified as a logical vector of the same size asx. Use 1 for observations that are right-censored and 0 for observations that are fully observed.

The default is an array of 0s, meaning that all observations are fully observed.

Data Types:logical

Frequency or weights of observations, specified as a nonnegative vector that is the same size asx. Thefreqinput argument typically contains nonnegative integer counts for the corresponding elements inx, but can contain any nonnegative values.

To obtain the weighted MLEs for a data set with censoring, specify weights of observations, normalized to the number of observations inx.

The default is an array of 1s, meaning one observation per element ofx.

Data Types:single|double

Optimization options, specified as a structure.optionsdetermines the control parameters for the iterative algorithm thatwblfituses to compute MLEs for censored data.

Createoptionsby using the functionstatsetor by creating a structure array containing the fields and values described in this table.

Field Name Value Default Value
Display

Amount of information displayed by the algorithm.

  • 'off'— Displays no information

  • 'final'— Displays the final output

  • 'iter'— Displays iterative output

'off'
TolX

Termination tolerance for the parameters, specified as a positive scalar

1e-8

You can also enterstatset('wblfit')in the Command Window to see the names and default values of the fields thatwblfitincludes in theoptionsstructure.

Example:statset('Display','iter')specifies to display the information from each step of the iterative algorithm.

Data Types:struct

Output Arguments

collapse all

Estimate of the parametersa(scale) andb(shape) of the Weibull distribution, returned as a row vector.

Confidence intervals for the mean parameters of the Weibull distribution, returned as a 2-by-2 matrix vector containing the lower and upper bounds of the100(1—alpha)% confidence interval.

The first and second rows correspond to the lower and upper bounds of the confidence intervals, respectively.

Alternative Functionality

wblfitis a function specific to Weibull distribution. Statistics and Machine Learning Toolbox™ also offers the generic functionsmle,fitdist, andparamciand theDistribution Fitterapp, which support various probability distributions.

  • mlereturns MLEs and the confidence intervals of MLEs for the parameters of various probability distributions. You can specify the probability distribution name or a custom probability density function.

  • Create aWeibullDistributionprobability distribution object by fitting the distribution to data using thefitdistfunction or theDistribution Fitterapp. The object propertiesaandbstore the parameter estimates. To obtain the confidence intervals for the parameter estimates, pass the object toparamci.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a