### 8.4.11 The geometric distribution

#### The probability density function for the geometric distribution: geometric

If an experiment with probability of success p is iterated, the probability that the first success occurs on the kth trial is (1−p)k−1p. This gives the geometric distribution (with parameter p) on the natural numbers. Given such a p, the geometric density function at n is given by geometric(p,n) = (1−p)n−1p. If you enter

geometric(0.2,3)

for example, you will get

0.128

#### The cumulative distribution function of the geometric distribution: geometric_cdf

The cumulative distribution function for the geometric distribution with parameter p at a natural number n is geometric_cdf(p,n) = Prob(X ≤ n), which in this case turns out to be geometric_cdf(p,n) = 1 − (1−p)n. If you enter

geometric_cdf(0.2,3)

for example, you will get

0.488

If you give geometric_cdf an extra argument k, also a natural number, you will get the probability that the random variable lies between the two values; geometric_cdf(p,n,k) = Prob(n ≤ X ≤ k). If you enter

geometric_cdf(0.2,3,5)

you will get

0.31232

#### The inverse distribution function for the geometric distribution: geometric_icdf

The inverse distribution function for the geometric distribution with parameter p is computed with geometric_icdf(p,h); recall that this will return the smallest natural number n with geometric_cdf(p,n) ≥ h. If you enter

geometric_icdf(0.2,0.5)

you will get

4