Binomial distribution
Binomial distribution: the number of successes in a fixed number of independent trials. With the default parameters (number of trials n = 20, probability of success p = 0.3) its mean is 6 and its standard deviation 2.0494. Use the simulator below to draw samples and see it take shape.
Simulate it
Change the parameters, then draw random samples. The bars are the samples; the dots are the exact probabilities. With more samples the bars settle onto it.
Samples to draw
What is the binomial distribution?
The binomial distribution counts the successes in n independent trials that each have the same probability p of success. Flip a coin 20 times and count the heads; check 50 items and count the defective ones; show an advert to 1,000 people and count the clicks.
It is the workhorse for yes or no data. Proportions in surveys, conversion rates in A/B tests, pass rates and defect rates all rest on it, and when n is large it is well approximated by the normal distribution, which is how most confidence intervals for proportions are built.
Where it is used
- Defective items in a batch of n, when each is defective with the same probability.
- Conversions among n website visitors in an A/B test.
- People who answer yes among n respondents in a large population.
- Heads in n coin flips.
- Seeds that germinate out of n planted.
Shape and parameters
The distribution is centred on np. It is symmetric when p = 0.5, skewed right when p is small and skewed left when p is large. For n large and p not near 0 or 1 it looks like a bell curve with mean np and standard deviation √(np(1 − p)), which is the normal approximation (a common rule is np ≥ 5 and n(1 − p) ≥ 5).
What it assumes
- A fixed number n of trials.
- Each trial has two outcomes.
- The trials are independent.
- The probability p is the same on every trial.
How it relates to other distributions
- Bernoulli distribution: A binomial is a sum of n independent Bernoulli trials.
- Poisson distribution: For large n and small p the binomial is close to a Poisson with λ = np.
- Hypergeometric distribution: Sampling without replacement from a small population gives the hypergeometric, not the binomial.
- Normal distribution: For large n the binomial is approximately normal.
Common mistakes
- Using it when the trials are not independent, for instance sampling without replacement from a small batch (use the hypergeometric).
- Using it when p changes from trial to trial.
- Applying the normal approximation when np or n(1 − p) is small.
How to work it out
- 1
The probability mass function (the formula that gives the shape):
- 2
Its mean (the long-run average) and variance (the spread):
- 3
Worked example with the default parameters (number of trials n = 20, probability of success p = 0.3): With n = 20 and p = 0.3, what is the probability of at least 8 successes?
LaTeX source of the formulas on this page
\[ P(X=k)=\binom{n}{k}p^{k}(1-p)^{n-k} \]
\[ \mu = np,\qquad \sigma^2 = np(1-p) \]
\[ \text{answer} = 0.2277 \]At a glance
| Property | Value |
|---|---|
| Type | Discrete (counts) |
| Parameters | number of trials n; probability of success p |
| Possible values | 0, 1, 2, …, n |
| Mean | 6 |
| Variance | 4.2 |
| Standard deviation | 2.0494 |
| Example (number of trials n = 20, probability of success p = 0.3) | With n = 20 and p = 0.3, what is the probability of at least 8 successes? Answer: 0.2277. |
How to compute it in Excel, Python and R
| Tool | Function |
|---|---|
| Excel / Google Sheets | =BINOM.DIST(k, n, p, FALSE) (TRUE for P(X ≤ k)) |
| Python (SciPy) | scipy.stats.binom.pmf(k, n, p) |
| R | dbinom(k, n, p) (pbinom for P(X ≤ k)) |
Questions
What is the binomial distribution used for?
The number of successes in a fixed number of independent trials. Typical uses: Defective items in a batch of n, when each is defective with the same probability. Conversions among n website visitors in an A/B test. People who answer yes among n respondents in a large population.
What are the mean and variance of the binomial distribution?
Mean: μ = np. Variance: σ² = np(1-p).
What does the binomial distribution assume?
A fixed number n of trials. Each trial has two outcomes. The trials are independent. The probability p is the same on every trial.
How do I calculate it in Excel?
=BINOM.DIST(k, n, p, FALSE) (TRUE for P(X ≤ k))
How is the binomial distribution related to other distributions?
Bernoulli distribution: A binomial is a sum of n independent Bernoulli trials. Poisson distribution: For large n and small p the binomial is close to a Poisson with λ = np. Hypergeometric distribution: Sampling without replacement from a small population gives the hypergeometric, not the binomial. Normal distribution: For large n the binomial is approximately normal.