### 20.4.11 Gamma distribution

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

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) (8)

The gammad command computes this density function.

- gammad takes three arguments:
  - a and b, positive real numbers (the parameters).
  - x, a real number.
- gammad(a,b,x) returns the value of the gamma density function with parameters a and b, given in (8).

#### Example

gammad(2,1,3)

3
e3

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

The gamma_cdf command computes the cumulative distribution function for the gamma distribution.

- gamma_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.
- gamma_cdf(a,b,x) returns Prob(X ≤ x) for the gamma distribution with parameters a and b.
- gamma_cdf(n,x,y) returns Prob(x ≤ X ≤ y).

It turns out that

gammad_cdf(n,x)=igamma(a,bx, 1),

where igamma is the incomplete gamma function (see Section 7.3.15),

igamma(a,x,1)=

1
Γ(a)

∫

x
0

e−tta−1d t.

#### Examples

gammad_cdf(2,1,0.5)

0.090204010431 |  |  |  |  |  |  |  |  |  |

gammad_cdf(2,1,0.5,1.5)

0.351970589198 |  |  |  |  |  |  |  |  |  |

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

The gammad_icdf command computes the inverse distribution for the gamma distribution.

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

#### Example

gammad_icdf(2,1,0.5)

1.67834699002 |  |  |  |  |  |  |  |  |  |