Contenu principal

betafit

Beta parameter estimates

Description

pHat= betafit(x) returns the maximum likelihood estimates (MLEs) of the beta distribution parameters a and b, given the data in x. For more information, see Beta Distribution.

[pHat,pCI] = betafit(x) also returns the 95% confidence intervals for the parameter estimates.

[pHat,pCI] = betafit(x,alpha) specifies the confidence level for the confidence intervals to be 100(1 – alpha)%.

example

Examples

collapse all

Generate 1000 random numbers from the beta distribution with the parameters a=3 and b=4.

rng(0,"twister") % For reproducibility
x = betarnd(3,4,[1000,1]);

Find the maximum likelihood estimates and 99% confidence intervals of a and b, .

[pHat,pCI] = betafit(x,0.01)
pHat = 1×2

    3.0889    4.1189

pCI = 2×2

    2.7644    3.6703
    3.4515    4.6222

The first column of pCI contains the lower and upper 99% confidence bounds for the beta a parameter, and the second column contains the confidence bounds for the beta b parameter.

Input Arguments

collapse all

Sample data, specified as vector of scalar values in the range [0,1]. When x contains exact zeros or ones, the beta likelihood function is unbounded, and standard maximum likelihood estimation is not possible. In this case, betafit maximizes a modified likelihood that incorporates the zeros or ones by treating them as values that are left-censored at sqrt(realmin) and right-censored at 1 – eps/2, respectively.

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.

Data Types: single | double

Output Arguments

collapse all

Estimates of the a and b parameters of the beta distribution, returned as a 1-by-2 row vector.

Confidence intervals for the parameter estimates of the beta distribution, returned as a 2-by-2 matrix of scalar values. The first column of pCI contains the lower and upper confidence bounds for the beta a parameter, and the second column contains the confidence bounds for the beta b parameter. The confidence intervals are based on a normal approximation for the distribution of the logs of the parameter estimates.

Alternative Functionality

betafit is a function specific to the beta 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 BetaDistribution 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.

References

[1] Hahn, Gerald J., and S. S. Shapiro. Statistical Models in Engineering. Hoboken, NJ: John Wiley & Sons, Inc., 1994, p. 95.

Extended Capabilities

expand all

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

Version History

Introduced before R2006a