NapkinCalc

Probability — Chance & Counting

Independent events & the binomial distribution

continues from lesson 2 — values defined earlier in the course stay live here

ELI5: when events don't affect each other (independent), multiply their probabilities — two coin flips both heads is ½ · ½ = ¼. Repeat a yes/no trial n times and the binomial formula gives the chance of exactly k successes: C(n, k)·pᵏ·(1−p)ⁿ⁻ᵏ.

ptwoheads=0.50.5p_{two_heads} = 0.5 \cdot 0.5 = 0.25000.2500 two independent flips, both heads
✓ pass ptwoheads==0.25p_{two_heads} == 0.25 one in four
pfive=combinations(10,5)0.550.55p_{five} = \mathrm{combinations}\left(10, 5\right) \cdot 0.5^{5} \cdot 0.5^{5} = 0.24610.2461 exactly 5 heads in 10 flips ≈ 0.246
✓ pass abs(pfive0.2461)<0.001\mathrm{abs}\left(p_{five} - 0.2461\right) < 0.001 the most likely single count — but still under 25%

Real-world hook: the binomial models quality control (defects per batch), A/B tests (conversions), and epidemiology (cases per exposed group).

Try it yourself: what is the probability of exactly 2 heads in 3 flips? (C(3, 2)·0.5²·0.5¹.)

probyou=combinations(3,2)0.53prob_{you} = \mathrm{combinations}\left(3, 2\right) \cdot 0.5^{3} = 0.37500.3750 ✏️ Your turn: compute P(exactly 2 heads in 3 flips) = C(3, 2)·(0.5)³. (It works out to 3/8.)
✓ pass abs(probyoucombinations(3,2)0.53)<0.000001\mathrm{abs}\left(prob_{you} - \mathrm{combinations}\left(3, 2\right) \cdot 0.5^{3}\right) < 0.000001 green when it matches the binomial probability

Where next: Statistics turns probability around — from "what will the data do?" to "what does the data we collected tell us?"