The Beta Distribution

The Beta distribution is often used to model random variables with a finite range. The Beta distribution is also used in Bayesian analysis.

The Beta distribution has two shape parameters, usually denoted by the Greek letters α and β. Its probability density function (PDF) is:

Probability density of the beta distribution.

Unlike most other distributions, location and scale parameters are not usually used to specify the general form of the Beta distribution. Instead, the lower and upper bounds of the definition interval are used.

For certain specific values of the parameters α and β, the beta distribution is equivalent to a simpler distribution. For α = β = 1, the beta distribution is equivalent to the uniform distribution. For α = 1 and β = 2, and α = 2 and β = 1, the beta distribution reduces to a triangular distribution. For α and β very large, the beta distribution approximates to the normal distribution.

The beta distribution is implemented by the BetaDistribution class. It has three constructors. The first constructor takes the two shape parameters, α and β as arguments. The following constructs a beta distribution with α = 1.5 and β = 0.8:

C#
var beta1 = new BetaDistribution(1.5, 0.8);

The second constructor takes two extra arguments that specify the lower and upper bound of the interval on which the beta distribution is defined. The default is a lower bound of 0 and an upper bound of 1. The following constructs a beta distribution with α = 1.5 and β = 0.8 over the interval [1, 4]:

C#
var beta2 = new BetaDistribution(1.5, 0.8, 1, 4);

If a variable is assumed to have a beta distribution, then the parameters of the distribution can be estimated using the method of matching moments. The third constructor performs this calculation. It takes one argument: a Vector<T> whose distribution is to be estimated. This constructor estimates a standard beta distribution, with lower bound and upper bound equal to 0 and 1, respectively.

Note that parameter estimation says nothing about how well the estimated distribution fits the variable's distribution. Use one of the goodness-of-fit tests to verify the appropriateness of the choice of distribution.

The BetaDistribution class has four specific properties that correspond to the parameters of the distribution. The Alpha and Beta properties return the shape parameters, α and β. The LowerBound and UpperBound properties return the bounds of the interval on which the beta distribution is defined.

BetaDistribution has one static (Shared in Visual Basic) method, Sample, which generates a random sample using a user-supplied uniform random number generator.

C#
var random = new MersenneTwister();
double sample = BetaDistribution.Sample(random, 1.5, 0.8);

For details of the properties and methods common to all continuous distribution classes, see the topic on continuous distributions..