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 in x.

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 be 100(1—alpha)%.

[___] = wblfit(x,alpha,censoring) specifies whether each value in x is right-censored or not. Use the logical vector censoring in 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 algorithm wblfit to use to compute maximum likelihood estimates (MLEs) with censoring. Create options by using the function statset.

You can pass in [] for alpha, censoring, and freq to use their default values.

Examples

collapse all

Generate 100 random numbers from the Weibull distribution with scale 0.8 and shape 3.

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

Estimate the parameters of the Weibull distribution from the data.

parmHat = wblfit(x)
parmHat = 1×2

    0.7751    2.9433

Generate 100 random numbers from the Weibull distribution with scale 1 and shape 2.

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

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

[parmHat,parmCI] = wblfit(x)
parmHat = 1×2

    0.9536    1.9622

parmCI = 2×2

    0.8583    1.6821
    1.0596    2.2890

The top row of parmCI contains 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 scale 2 and shape 5.

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

Display the algorithm parameters for wblfit.

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 function statset. 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×2

    1.9624    4.9050

wblfit displays 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 is 100(1—alpha)%, where alpha is 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 in x, specified as a logical vector of the same size as x. 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 as x. The freq input argument typically contains nonnegative integer counts for the corresponding elements in x, 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 in x.

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

Data Types: single | double

Optimization options, specified as a structure. options determines the control parameters for the iterative algorithm that wblfit uses to compute MLEs for censored data.

Create options by using the function statset or by creating a structure array containing the fields and values described in this table.

Field NameValueDefault 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 enter statset('wblfit') in the Command Window to see the names and default values of the fields that wblfit includes in the options structure.

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 parameters a (scale) and b (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 the 100(1—alpha)% confidence interval.

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

Alternative Functionality

wblfit is a function specific to Weibull distribution. Statistics and Machine Learning Toolbox™ also offers the generic functions mle, fitdist, and paramci and the Distribution Fitter app, which support various probability distributions.

  • mle returns 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 a WeibullDistribution probability distribution object by fitting the distribution to data using the fitdist function or the Distribution Fitter app. The object properties a and b store the parameter estimates. To obtain the confidence intervals for the parameter estimates, pass the object to paramci.

Extended Capabilities

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

Version History

Introduced before R2006a