### 7.4.1 The binomial distribution

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

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

This determines the binomial distribution, and so this is called the binomial command. If you enter

binomial(10,2,0.4)

you will get

0.120932352

If no third argument p is given, then binomial will just compute (kn), which recall is called the binomial coefficient and is also computed by comb. If you enter

binomial(10,2)

or

comb(10,2)

then you will get

45

#### The cumulative distribution function for the binomial distribution: binomial_cdf

Recall that the cumulative distribution function (cdf) for a distribution is cdf(x) = Prob(X ≤ x). For the binomial distribution, this is given by the binomial_cdf command; binomial_cdf(n,p,x), which in this case will equal binomial(n,0,p) + …+ binomial(n,floor(x,p). If you enter

binomial_cdf(4,0.5,2)

you will get

0.6875

You can give binomial_cdf an additional argument; binomial_cdf(n,p,x,y) = Prob(x ≤ X ≤ y), which in this case would be binomial(n,ceil(x),p) + ⋯ + binomial(n,floor(y),p). If you enter

binomial_cdf(2,0.3,1,2)

you will get

0.51

#### The inverse distribution function for the binomial distribution: binomial_icdf

Given a value h, the inverse distribution function gives the value of x so that Prob(X ≤ x) = h; or for discrete distributions, the smallest x so that Prob(X ≤ x) ≥ h. For the binomial distribution with n and p, the binomial_icdf gives the inverse distribution function. If you enter

binomial_icdf(4,0.5,0.9)

you will get

3

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