### 7.4.10 The beta distribution

#### The probability density function for the beta distribution: betad

The beta distribution depends on two parameters, a>0 and b>0; the value of the density function at x in [0,1] is betad(a,b,x) = Γ(a+b)xa−1(1−x)b−1/(Γ(a)Γ(b)). If you enter

betad(2,1,0.3)

for example, you will get

0.6

#### The cumulative distribution function for the beta distribution: betad_cdf

The cumulative distribution function for the beta distribution with parameters a and b at a value x in [0,1] is betad_cdf(a,b,x) = Prob(X ≤ x). It turns out that betad_cdf(a,b,x) = β(a,b,x)Γ(a+b)/(Γ(a)Γ(b)) where β(a,b,x) = ∫0x ta−1(1−t)b−1 dt. If you enter

betad_cdf(2,3,0.2)

for example, you will get

0.1808

If you give betad_cdf an extra argument y, also in [0,1], you will get the probability that the random variable lies between the two values; betad_cdf(a,b,x,y) = Prob(x ≤ X ≤ y). If you enter

betad_cdf(2,3,0.25,.5)

you will get

0.42578125

#### The inverse distribution function for the beta distribution: betad_icdf

The inverse distribution function for the beta distribution with parameters a and b is computed with betad_icdf(a,b,h); recall that this will return the value x with betad_cdf(a,b,x) = h. If you enter

betad_icdf(2,3,0.2)

you will get

0.212317128278