📘 CodingMarble Learn

Binomial Distribution

Repeat the same yes/no trial n times, independently, with the same chance of success p each time. The number of successes X follows the binomial distribution B(n, p): P(X = k) = ⁿCₖ pᵏ qⁿ⁻ᵏ with q = 1 − p. Its mean is np and its variance is npq.

🎬 Step-by-step story

  1. One trial has only two results: success (green) or failure (grey). The chance of success is p = 0.3, so the chance of failure is q = 0.7.
  2. Now do the same trial 4 times. The trials do not affect each other. The order S S F F has chance 0.3 × 0.3 × 0.7 × 0.7 = 0.0441.
  3. Exactly 2 successes can happen in 6 different orders. Count the rows: ⁴C₂ = 6. So P(X = 2) = 6 × 0.0441 ≈ 0.265.
  4. Do the same for 0, 1, 2, 3 and 4 successes. The bars show all the chances. Together they add up to 1.
  5. With 10 trials and p = 0.3, the tallest bar is near 3. That is the mean, np = 3. The spread is the variance, npq = 2.1.
  6. Your turn: change n and p with the sliders. Run 100 real experiments and compare the blue dots with the bars.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Why do we multiply the chances along one order?

The trials are independent, so the chance of “this AND this AND this” is the product. Step 2 shows 0.3 × 0.3 × 0.7 × 0.7.

Why is P(X = 2) not just 0.3² × 0.7²?

That is only one order. There are 6 orders with 2 successes; count the six rows in step 3.

Do all the probabilities really add to 1?

Yes. X must be one of 0, 1, …, n, and the terms are the expansion of (q + p)ⁿ = 1. See all bars in step 4.

Is the most likely value always exactly np?

Not always exactly, but the tallest bar is always next to np. In step 5, np = 3 and the tallest bar is at 3.

Why don't my real results match the formula exactly?

Random samples fluctuate. Run 100 experiments several times in free play: the dots jump around the bars but stay close.

What changes when p gets bigger?

The bars shift to the right because more successes become likely. Try it with the p slider.

Bernoulli trials: one yes/no experiment

A Bernoulli trial is an experiment with only two results. We call one result success and the other failure. Success has probability p. Failure has probability q = 1 − p.

Examples: a coin shows heads or not; a seed sprouts or not; a penalty is scored or not.

A random variable that is 1 for success and 0 for failure follows the Bernoulli law. Its mean is p and its variance is p(1 − p).

When is a situation binomial?

Check four things (remember BINS):

If all four hold, X = number of successes follows B(n, p). Drawing cards with replacement is binomial. Drawing without replacement is not, because p changes (see the hypergeometric section).

The binomial formula, step by step

Think of a tree diagram with n levels. One path with k successes and n − k failures has probability pᵏ qⁿ⁻ᵏ (multiply along the path, because the trials are independent).

How many such paths are there? We must choose which k of the n places are successes: ⁿCₖ ways.

P(X = k) = ⁿCₖ pᵏ qⁿ⁻ᵏ,  k = 0, 1, …, n

Where ⁿCₖ = n! ÷ (k! (n − k)!). The name comes from the binomial theorem: the terms of (q + p)ⁿ are exactly these probabilities, so they add up to (q + p)ⁿ = 1ⁿ = 1.

Mean, variance and the shape of the graph

X is the sum of n Bernoulli variables, each with mean p and variance pq. So:

The tallest bar (the mode) is always near np. When p = 0.5 the graph is symmetric. When p is small the graph leans to the left; when p is big it leans to the right. When n is large, the bar chart looks like a bell curve.

Simulation, fluctuation and a first idea of testing

A computer can simulate a trial: pick a random number between 0 and 1; if it is less than p, count a success. Repeat to get samples.

Different samples give different results. This is sampling fluctuation. For a sample of size n, the share of successes f usually lies in the interval p − 1/√n to p + 1/√n (about 95% of samples, when n ≥ 25 and 0.2 ≤ p ≤ 0.8).

Idea of a test: a firm says 50% of people like its drink. In a fair sample of 100 people only 35 do. The interval is 0.5 ± 0.1 = [0.4, 0.6]. 0.35 is outside, so we doubt the claim. A poll can also be biased if the sample is not chosen at random, for example asking only people inside the firm's own shop.

Without replacement: the hypergeometric distribution

A box has N items, K of them “good”. We pick n items without putting them back. X = number of good items picked.

P(X = k) = ᴷCₖ × ᴺ⁻ᴷCₙ₋ₖ ÷ ᴺCₙ

Its mean is also n × K/N. The trials are not independent, so it is not binomial. If N is very large compared with n, the hypergeometric is almost the same as B(n, K/N).

Try it: predict, then check

Toss 4 coins together 32 times and count heads each time. First predict: B(4, 0.5) says 0 heads about 2 times, 1 head about 8 times, 2 heads about 12 times, 3 heads about 8 times, 4 heads about 2 times. Now toss and tally. Then press “Run 100 times” in the 3D with n = 4, p = 0.5 and compare.

Key formulas and definitions

Worked examples

1. A fair coin is tossed 5 times. Find the probability of exactly 3 heads.

n = 5, p = 0.5, k = 3. P = ⁵C₃ × 0.5³ × 0.5² = 10 × 1/32 = 10/32 = 0.3125.

2. A bowler hits the stumps with probability 0.3 on each ball. In 6 balls, find P(exactly 2 hits).

n = 6, p = 0.3, q = 0.7. P = ⁶C₂ × 0.3² × 0.7⁴ = 15 × 0.09 × 0.2401 ≈ 0.324.

3. 5% of bulbs are faulty. A sample of 20 is chosen at random. Find P(no faulty bulb) and P(at least one).

P(X = 0) = 0.95²⁰ ≈ 0.358. P(X ≥ 1) = 1 − 0.358 = 0.642.

4. X ~ B(10, 0.4). Find the mean, variance and standard deviation.

Mean = np = 4. Variance = npq = 10 × 0.4 × 0.6 = 2.4. σ = √2.4 ≈ 1.55.

5. The mean of a binomial variable is 6 and its variance is 4.2. Find n and p.

npq ÷ np = q = 4.2 ÷ 6 = 0.7, so p = 0.3. n = 6 ÷ 0.3 = 20.

6. How many times must a fair die be rolled so that P(at least one six) > 0.9?

P(at least one six) = 1 − (5/6)ⁿ > 0.9 ⇒ (5/6)ⁿ < 0.1. (5/6)¹² ≈ 0.112, (5/6)¹³ ≈ 0.093. So n = 13 rolls.

7. A bag has 6 red and 4 blue marbles. 3 are drawn without replacement. Find P(exactly 2 red).

Hypergeometric: ⁶C₂ × ⁴C₁ ÷ ¹⁰C₃ = 15 × 4 ÷ 120 = 0.5. (With replacement it would be ³C₂ × 0.6² × 0.4 = 0.432.)

Common mistakes

Practice quiz

1. Which is NOT needed for a binomial setting?
2. X ~ B(8, 0.25). The mean of X is:
3. P(X = k) for B(n, p) equals:
4. X ~ B(10, 0.5). Var(X) =
5. Drawing 3 cards without replacement and counting aces follows the:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

What is the binomial distribution in simple words?

It gives the chance of getting exactly k successes when you repeat the same yes/no trial n times and the trials do not affect each other.

What is the difference between Bernoulli and binomial?

A Bernoulli trial is one yes/no experiment. The binomial distribution counts the successes in n such independent trials. B(1, p) is the Bernoulli law.

Why is the mean of a binomial distribution np?

Each trial adds on average p successes, and there are n trials, so the average total is n × p.

Where this is taught

NetherlandsHAVO 5 (eindexamenjaar)Statistics and probability (part 2)
England (GCSE, A level)Year 12M-N Probability and binomial distribution
USA (Common Core, NGSS, AP)Grade 12Probability, Random Variables, and Probability Distributions
South Korea고등학교 2학년Statistics
South Korea고등학교 3학년Statistics
Germany (Bavaria)Jahrgangsstufe 12Random variables and binomial distribution
FranceTerminaleStudy themes
FranceTerminaleProbability
FranceTerminaleMathematics (2019 programme)
Russia9 классBernoulli trials
Russia10 классTrials and combinatorics
Russia10 классCombinatorics and trials
China高三Ch.7 Random variables

Learn first

Related lessons

All Maths lessons