Beta Distribution



Statistics and Machine Learning Toolbox™ provides several ways to work with the beta distribution. You can use the following approaches to estimate parameters from sample data, compute the pdf, cdf, and icdf, generate random numbers, and more.

  • Fit a probability distribution object to sample data, or create a probability distribution object with specified parameter values. See Using BetaDistribution Objects for more information.

  • Work with data input from matrices, tables, and dataset arrays using probability distribution functions. See Supported Distributions for a list of beta distribution functions.

  • Interactively fit, explore, and generate random numbers from the distribution using an app or user interface.

For more information on each of these options, see Working with Probability Distributions.


The beta distribution uses the following parameters.

aFirst shape parametera>0
bSecond shape parameterb>0

Probability Density Function


The probability density function (pdf) of the beta distribution is


where B( · ) is the Beta function. The indicator function I(0,1)(x) ensures that only values of x in the range (0,1) have nonzero probability.


This plot shows how changing the value of the parameters alters the shape of the pdf. The constant pdf (the flat line) shows that the standard uniform distribution is a special case of the beta distribution, which occurs when a = b = 1.

X = 0:.01:1;
y1 = betapdf(X,0.75,0.75);
y2 = betapdf(X,1,1);
y3 = betapdf(X,4,4);

hold on
hold off

Relationship to Other Distributions



If Y~t(v), then Xβ(ν2,ν2)


Cumulative Distribution Function

The beta cdf is the same as the incomplete beta function.




The function betafit returns the MLEs and confidence intervals for the parameters of the beta distribution. Here is an example using random numbers from the beta distribution with a = 5 and b = 0.2.

rng default  % For reproducibility
r = betarnd(5,0.2,100,1);
[phat, pci] = betafit(r)
phat = 1×2

    7.4911    0.2135

pci = 2×2

    5.0861    0.1744
   11.0334    0.2614

The MLE for parameter a is 7.4911, compared to the true value of 5. The 95% confidence interval for a goes from 5.0861 to 11.0334, which does not include the true value. While this is an unlikely result, it does sometimes happen when estimating distribution parameters.

Similarly the MLE for parameter b is 0.2135, compared to the true value of 0.2. The 95% confidence interval for b goes from 0.1744 to 0.2614, which does include the true value. In this made-up example you know the “true value.” In experimentation you do not.

See Also

Related Topics