### 8.4.9 The gamma distribution

#### The probability density function for the gamma distribution: gammad

The gamma distribution depends on two parameters, a>0 and b>0; the value of the density function at x ≥ 0 is gammad(a,b,x) = xa−1e−bxba/Γ(a). If you enter

gammad(2,1,3)

for example, you will get

3/exp(3)

#### The cumulative distribution function for the gamma distribution: gammad_cdf

The cumulative distribution function for the gamma distribution with parameters a and b at a value x is gammad_cdf(n,x) = Prob(X ≤ x). It turns out that gammad_cdf(n,x) = igamma(a, bx, 1) where igamma is the incomplete gamma function; igamma(a,x,1) = ∫0x e−tta−1dt/Γ(a). If you enter

gammad_cdf(2,1,0.5)

you will get

0.090204010431

If you give gammad_cdf an extra argument, you will get the probability that the random variable lies between two values; gammad_cdf(a,b,x,y) = Prob(x ≤ X ≤ y). If you enter

gammad_cdf(2,1,0.5,1.5)

you will get

0.351970589198

#### The inverse distribution function for the gamma distribution: gammad_icdf

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

gammad_icdf(2,1,0.5)

you will get

1.67834699002