### 20.4.12 Beta distribution

##### The probability density function for the beta distribution.

The beta distribution depends on two parameters, a>0 and b>0; the value of the density function at x in [0,1] is (see Section 7.3.13):

betad(a,b,x)=

Γ(a+b)xa−1(1−x)b−1
Γ(a)Γ(b)

. (9)

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

betad(2,1,0.3)

0.6 |  |  |  |  |  |  |  |  |  |

##### The cumulative distribution function for the beta distribution.

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 d t (see Section 7.3.16).

#### Examples

betad_cdf(2,3,0.2)

0.1808 |  |  |  |  |  |  |  |  |  |

betad_cdf(2,3,0.25,0.5)

0.42578125 |  |  |  |  |  |  |  |  |  |

##### The inverse distribution function for the beta distribution.

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

betad_icdf(2,3,0.2)

0.212317128278 |  |  |  |  |  |  |  |  |  |