Binomial distribution

### 20.4.3 Binomial distribution

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

If you perform an experiment n times where the probability of success each time is p, then the probability of exactly k successes is:

binomial(n,k,p)= | ⎛ ⎝ |
n
k
| ⎞ ⎠ | pk (1−p)n−k (1)

This determines the binomial distribution.

The binomial command computes the density function for the binomial distribution.

- binomial takes two mandatory arguments and one optional argument.
  - n, a positive integer.
  - k, a nonnegative integer less than or equal to n.
  - Optionally, p, a probability (a real number between 0 and 1).
- binomial(n,k) returns the binomial coefficient (kn) (see Section 12.1.2), same as comb(n,k).
- binomial(n,k,p) returns the probability given by (1).

#### Examples

binomial(10,2)

or:

comb(10,2)

45 |  |  |  |  |  |  |  |  |  |

binomial(10,2,0.4)

0.120932352 |  |  |  |  |  |  |  |  |  |

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

The binomial_cdf command computes the cumulative distribution function for the binomial distribution.

- binomial_cdf takes three mandatory arguments and one optional argument:
  - n, a positive integer.
  - p, a probability (a real number between 0 and 1).
  - x, a real number.
  - Optionally, y, a real number.
- binomial_cdf(n,p,x) returns

  Prob(X ≤ x)=binomial(n,0,p)+⋯+ binomial(n,⌊ x⌋),p)

- binomial_cdf(n,p,x,y) returns

  Prob(x ≤ X ≤ y)=binomial(n,⌈ x⌉,p)+⋯+ binomial(n,⌊ y⌋,p)

#### Examples

binomial_cdf(4,0.5,2)

0.6875 |  |  |  |  |  |  |  |  |  |

binomial_cdf(2,0.3,1,2)

0.51 |  |  |  |  |  |  |  |  |  |

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

The binomial_icdf command computes the inverse distribution function for the binomial distribution.

- binomial_icdf takes three mandatory arguments and one optional argument:
  - n, a positive integer.
  - p, a probability (a real number between 0 and 1).
  - h, a real number between 0 and 1.
- binomial_icdf(n,p,h) returns the value of the inverse distribution for the binomial distribution with n trials and probability p; namely, the smallest value of x for which Prob(X ≤ x) ≥ h.

#### Example

binomial_icdf(4,0.5,0.9)

3 |  |  |  |  |  |  |  |  |  |

Note that binomial_cdf(4,0.5,3)=0.9375, which is bigger than 0.9, while binomial_cdf(4,0.5,2)=0.6875, which is smaller than 0.9.