9.4.3 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) = | ⎛
⎝ | | ⎞
⎠ | 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 6.6.2), same as
comb(n,k)
- binomial(n,k,p) returns the probability given by
(1).
Examples.
-
Input:
binomial(10,2)
or:
comb(10,2)
Output:
- Input:
binomial(10,2,0.4)
Output:
The cumulative distribution function for the binomial distribution: binomial_cdf
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,floor(x),p)
|
- binomial_cdf(n,p,x,y) returns
Prob(x ≤ X ≤ y) = binomial(n,ceil(x),p) + … +
binomial(n,floor(y),p)
|
Examples.
-
Input:
binomial_cdf(4,0.5,2)
Output:
- Input:
binomial_cdf(2,0.3,1,2)
Output:
The inverse distribution function for the binomial distribution: binomial_icdf
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.
Input:
binomial_icdf(4,0.5,0.9)
Output:
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.