The geometric distribution

### 8.4.13 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 (10)

The geometric command computes this density function.

- geometric takes two arguments:
  - p, a probability (a number between 0 and 1).
  - x, a real number.
  geometric(p,x) returns the value of the geometric density function with probability p, given in (10).

#### Example

Input:

geometric(0.2,3)

Output:

0.128

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

The geometric_cdf command computes the cumulative distribution function for the geometric distribution.

- geometric_cdf takes three mandatory arguments and one optional argument:
  - p, a probability (a number between 0 and 1).
  - n, a natural number.
  - Optionally, k, a natural number.
- betad_cdf(p,n) returns Prob(X ≤ n) for the geometric distribution with probability p.
- beta_cdf(p,n,k) returns Prob(n ≤ X ≤ k).

It turns out that geometric_cdf(p,n) = 1 − (1−p)n.

#### Examples

- Input:
  geometric_cdf(0.2,3)
  Output:

  0.488

- Input:
  geometric_cdf(0.2,3,5)
  Output:

  0.31232

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

The geometric_icdf command computes the inverse distribution for the geometric distribution.

- geometric_icdf takes two arguments:
  - p, a probability (a number between 0 and 1).
  - h, a real number between 0 and 1.
- geometric_icdf(a,b,h) returns the inverse distribution for the geometric distribution with probability p; namely, the smallest natural number n for which Prob(X ≤ n) ≥ h.

#### Example

Input:

geometric_icdf(0.2,0.5)

Output:

4