The beta distribution

### 9.4.12 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)) (9)

(see Section 6.8.13).
The betad command computes the density function for the beta distribution.

- betad takes three arguments:
  - a and b, positive numbers, the parameters.
  - x, a real number.
- betad(a,b,x) returns the value of the density function for the beta distribution with parameters a and b, given in (9).

Example.
Input:

betad(2,1,0.3)

Output:

0.6

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

The betad_cdf command computes the cumulative distribution function for the beta distribution.

- beta_cdf takes three mandatory arguments and one optional argument:
  - a and b, real numbers (the parameters).
  - x, a real number.
  - Optionally, y, a real number.
- betad_cdf(a,b,x) returns Prob(X ≤ x) for the beta distribution with parameters a and b.
- beta_cdf(n,x,y) returns Prob(x ≤ X ≤ y).

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 (see Section 6.8.16).

Examples.

- Input:
  betad_cdf(2,3,0.2)
  Output:

  0.1808

- Input:
  betad_cdf(2,3,0.25,0.5)
  Output:

  0.42578125

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

The betad_icdf command computes the inverse distribution for the beta distribution.

- beta_icdf takes three arguments:
  - a and b, real numbers (the parameters).
  - h, a real number between 0 and 1.
- beta_icdf(a,b,h) returns the inverse distribution for the beta distribution with parameters a and b; namely, the value of x for which Prob(X ≤ x) = h.

Example.
Input:

betad_icdf(2,3,0.2)

Output:

0.212317128278