◈ probability mapProb · Ch 09/16
Probability from the coin flip up · chapter 09

09Bernoulli → Binomial

Last chapter ended with a promise, and here is the payout up front: the binomial is not a new object at all. It is just n atoms added up. That is one of the most satisfying moves in all of probability, and the rest of the chapter is us earning the right to believe it. The atom arrived at the end of last chapter. We had just met the random variable — a number bolted onto every outcome — and we pointed at the simplest one there is: a single yes/no. Did the coin land heads? Did the part fail? One trial, two outcomes, and a probability p on the one you call a success. That two-valued speck is the Bernoulli random variable, the hydrogen atom of this whole subject. Stack n of these, count the successes, and you have built the first real distribution. This chapter cashes that promise, and I want to go slowly, because a small miracle hides in the middle. First we build the atom and read its two honest numbers: mean p, spread pq. Then we stack n of them into the hub and watch a histogram assemble itself from nothing but coin flips. Then we read the binomial's formula not as something to memorize but as a sentence: P(X=k) = C(n,k) arrangements, times pᵏ for the successes, times q^(n−k) for the failures. We will see exactly why that C(n,k) shows up — for 2 heads in 4 flips it is C(4,2) = 6 arrangements — which is the whole reason Chapter 2's counting engine was worth building. We will prove the bars sum to one, not by checking them, but because the binomial theorem guarantees it: (p+q)ⁿ = 1ⁿ = 1. And at the end we stand the hub on the family tree, where one knob — common-and-many versus rare-and-many — forks it into the two great distributions of the next two chapters, the Normal and the Poisson. One atom, stacked and counted. That's the whole chapter.

01The atom: one yes/no

Chapter 8 ended by defining the smallest possible random variable, and it is worth standing still on it for a moment. Take any single yes/no event. Assign it 1 when it happens and 0 when it doesn't, with probability p of the 1. That is the whole object. There is nothing simpler in discrete probability, no smaller moving part. It has a name, the Bernoulli random variable, after the family of mathematicians who first pinned it down. So let's just hold it in your hand before we do anything with it. Here it is: one weighted flip, two bars. Drag p and watch the two possibilities trade height. Weight p sits on success. Weight q = 1 − p sits on failure.

one trial · X ∈ {0, 1} 1.0 0.5 0 p = 0.60 q = 0.40 X = 1 (success) X = 0 (failure) weight p weight q p + q = 1 always
p=0.60 q=0.40 sum=1.00
Grab the white dot (or the slider) — pick any p, and q locks to 1−p automatically. That's the whole atom: one number, and normalization does the rest.
Fig. 1. One trial, one number: X can only land on 1 (success) or 0 (failure), and p is the chance it lands on 1. Drag the white dot — the green bar's height is p, the red bar's height is q, and q is never something you set: it's forced to be 1 − p, so the two bars always meet at a full bar's worth of probability. That's the atom of discrete probability — no smaller moving part exists than one number deciding a yes-or-no, with normalization (p + q = 1) doing the rest for free.

Notice the one constraint baked in. The two bars always add to 1, because p + q = 1. Something has to happen, success or failure, and there is no third door. That is Chapter 3's normalization axiom showing up in its tiniest possible form. Now here is the thing most treatments rush past, and it is worth slowing down for: what counts as a success is entirely your call. The atom doesn't know or care whether the 1 means "heads," "the part is defective," "the user clicked," or "the patient recovered." You point the atom at a phenomenon and you decide which outcome wears the 1. Swap the label and the same machine describes four completely different worlds.

🪙 COIN FLIP p = 50% one trial → X ∈ {0,1}, P(X=1) = p TAILS (1−p = 50%) HEADS (p = 50%) 0 → flip one fair coin
here, "1" means: HEADS
Same 0/1-and-p atom every time — only the labels swap. Success is whichever outcome we point 1 at, not a fact the world hands you.
Fig. 2. The same Bernoulli atom, four costumes: one trial, outcome 0 or 1, weighted by p — that line at the top never changes. What changes when you click Coin / Part / Ad / Patient is only which real event gets the label 1 and how likely it is: a coin's heads (p=50%), a factory's defective part (p=4%), an ad's click (p=3%), a drug's cure (p=70%). Same maths, same bar, same split — success is a modelling decision, which is exactly why this one atom shows up in reliability engineering, A/B testing, quality control, and machine learning at once.

Same two outcomes, same probability p, four different stories. That is why this one atom shows up in reliability engineering, in A/B testing, in quality control, in medicine, and in machine learning. Success is a modelling decision, not a fact about the world. Good. Now let's read the atom's two honest summary numbers, because they are the seeds of everything the binomial will inherit. A Bernoulli has a mean and a spread, and both are almost embarrassingly simple. The mean weights each outcome by its probability: 0·q + 1·p = p. The variance, which is the spread, works out to pq. Set the success chance to 0.3 and the atom averages 0.3 per trial, with a variance of 0.3 × 0.7 = 0.21. Drag p and watch where the fulcrum balances and how the spread meter swells.

E[X] = p = 0.50 drag p — the fulcrum finds the balance point 0 .25 .5 .75 1 0: q=0.50 1: p=0.50 spread meter Var = pq = 0.2500 ¼ max 0
Var = 0.250 (peak)
peak spread — most unpredictable
Fig. 3. Two outcomes, 0 and 1, sit at the ends of a beam carrying mass q and mass p. Drag p and the gold fulcrum slides to exactly that position — because a beam pivoted at p with those two masses is always in torque balance (that's the whole definition of a mean). Watch the weights swap size as p moves: at the edges one weight vanishes and the beam is trivially balanced — a certain outcome, zero surprise. On the right, the gold spread meter tracks Var = pq: it swells to its ceiling of ¼ exactly at p=½, the fair coin that can least be predicted, and drains to 0 at both ends. Stack n of these atoms later and these same two numbers scale up for free — E[X]=p becomes np, Var=pq becomes npq.

Feel what the spread meter just told you. pq is largest at p = ½, where it reaches ½ × ½ = 0.25, and it shrinks to zero at either end. That is deeply sensible. A fair coin is the most uncertain atom there is, because you genuinely can't guess it. A coin that is certain to land heads (p = 1) has no spread at all, because it isn't really random anymore. Hold onto E = p and Var = pq. In a few pages they will become np and npq almost for free. But one atom is a boring random variable. It only ever says 1 or 0. The interesting thing happens when we start stacking them.

02Stacking atoms into the hub

Here is the entire idea of this chapter in one sentence, and everything else is us earning the right to believe it. The binomial is nothing but a sum of n independent Bernoulli atoms. That's it. Take n identical coins, each a Bernoulli with the same p, flip them all, and let X be the count of successes. That count is a new random variable. It can be 0, 1, 2, … , n, and its distribution is the Binomial(n, p). Don't take my word for the shape; let's build it. Below, n little atoms each fire a 1 or a 0. A counter adds them into today's X. Hit it again and again, and the running histogram of those counts stacks up in front of you. Slide p to skew the atoms and watch the pile lean.

fire n atoms · count the 1s · · · · · · · · · · count of 1s = today's X X = – one trial = n atoms added the pile of X over many trials trials 0 n·p 0 1 2 3 4 5 6 7 8 9 10 X = number of 1s (no curve drawn — only tallies)
fire the atoms — watch X appear
Binomial isn't a new object: it's n Bernoulli atoms added, counted, and piled up.
Fig. 4. The Bernoulli → Binomial adder. Each blue circle is one Bernoulli atom — it fires a 1 with probability p and a 0 otherwise. Fire once and every atom flips; the count of 1s is today's X. Do it again and again — run ×50 — and each count drops a tally onto the pile at right. No curve is ever drawn: the histogram is discovered, built purely by stacking real trials. That pile is the Binomial(n, p) — not a new object, just n atoms added and counted, over and over. Slide p and the whole pile leans toward its balance point n·p; that's why the binomial's shape was never imposed — it falls out of the adding.

That growing pile is the binomial. It is not a formula we imposed. It is the natural shape that falls out of counting successes across many trials. But watch that word independent, because the whole construction leans on it. It leans on one more condition too: the atoms must be identical, with the same p on every trial. Those two conditions together have a name you'll meet everywhere in probability and statistics. The trials are i.i.d., independent and identically distributed. Break independence and the clean binomial quietly falls apart. Break the same-p condition and it falls apart just as fast. Let's actually break it. Wire a shared cause between the atoms so they stop being independent, and watch the tidy hump clump and distort.

P(k) 0 .20 .40 0 1 2 3 4 5 6 k successes out of n = 6 coin-atoms spread of k (std dev) σ: sim 0.00 vs formula 1.22 → each atom's still a fair coin — only their independence broke
clean bell — matches the binomial
n = 6 atoms · runs 0
at 100%, one shared coin decides all 6 atoms — 0 or 6, nothing between.
Fig. 5. Seven bins, k = 0..6 — how many of n = 6 fair-coin atoms come up heads. The dashed gold outline is the true binomial reference, fixed from the formula and never moving. The solid bars are a live simulation that rebuilds itself the instant you move coupling: at 0% each atom flips its own free coin and the bars hug the reference — a clean hump. Drag toward 100% and one shared "hub" atom starts deciding its neighbours too; each atom is still a fair coin on its own, so the hump doesn't shift — but it splits, piling up at 0 and 6 because entire runs now agree together. The spread meter makes it precise: the simulated std dev of k pulls away from the formula's fixed 1.22, up to 3.00 at full coupling — proof the trials were never really separate. That's why "independent, identically distributed" is two conditions, not one: this run stayed identically distributed the whole time, and broke anyway.

The coupling slider broke independence while keeping every atom a fair coin. The world's most common break is sneakier: draw cards from a deck without putting them back. A full deck gives a heart 13/52 = 0.25. Pull that heart and the next draw is 12/51 ≈ 0.235. Each card you take changes what is left, so p is no longer fixed. Watch the chance shift with every draw, and watch the binomial reference miss.

THE DECK · 5 red / 5 blue chance the NEXT card is red: 0.50 = 5 / 10 dealt 0 of 5 · reds drawn 0 count of reds in 5 draws runs: 0 measured spread of the pile σ = — Binomial(5,½): σ = 1.118 np = 2.5 k = reds in the 5-card draw
p starts at 5/10 = 0.50
Deal one card at a time and watch the chance drift; then run ×2000 and compare the pile's spread to the dashed binomial.
Fig. 6. A deck of ten — five red, five blue — draw five, count reds. Hit deal next card and watch the success chance drift: it starts at 5/10 = 0.50, but draw a red and the next is 4/9 ≈ 0.44; draw a blue and it jumps to 5/9 ≈ 0.56. Now run ×2000 and the pile of red-counts stacks up against the fixed dashed Binomial(5, ½). The mean sits right where the binomial says — np = 2.5 — so you almost trust it. But the spread is wrong: the measured σ ≈ 0.83 is visibly tighter than the binomial's 1.118, because each draw quietly changed the next. Flip put cards back on and the drift freezes at 0.50, the trials go independent, and the bars fuse onto the reference (σ ≈ 1.12). "Same p, independent" isn't paperwork: break it and Var = npq is simply the wrong number.

You have watched the atom stack into a binomial, and you have watched that stack fall apart. The real skill is spotting a genuine binomial before you trust one. Every binomial hides three questions. How many trials are there, which is n? What is the success chance p? And are the trials truly i.i.d.? Below are real situations. For each one, name the atom yourself, then check whether the fine print holds.

🪙 10 fair coin flips count how many land heads your atom: n=10 · p=0.50 textbook: n=10 · p=0.50 ? fixed number of trials n? ? same p on every trial? ? trials independent? tick the conditions · commit · reveal
commit yes or no, then reveal
— the broken atom, if any, is named here —
correct 0 / 5 · seen 0 / 5
Fig. 7. A modelling drill, not a formula drill. For each card set n and p, judge the three i.i.d. conditions, commit YES or NO, then reveal: each condition lights green (holds) or red (broken), and every imposter names the atom that failed — the 🃏 deck shrinks, so p isn't fixed; the 🏥 shared infection links patients, so trials aren't independent; the 🏭 defect rate creeps, so p isn't identical. Only 🪙 (10, ½) and 🎲 (12, 1/6) survive all three. The aha the scoreboard lands: three of five look like repeated yes/no trials, but only two are binomial — the formula was never the hard part; deciding whether you're allowed to use it is.

So the binomial is a promise with fine print: n trials, independent, each with the same p. When that fine print holds, the count's distribution is completely pinned down. It is also small enough to work out by hand, which is exactly what we should do before trusting any formula. Let's enumerate. For n = 2 flips there are four equally-likely sequences, since 2² = 4 — they are HH, HT, TH, TT. Bin them by number of heads and they fall into counts 1, 2, 1. Step it up to n = 3 and the eight sequences, since 2³ = 8, bin into 1, 3, 3, 1. Watch each sequence drop into its count's bin.

all 2-flip sequences binned by number of heads (k) 0 0 0 0 k=0 k=1 k=2 k=3
how many flips?
click step to begin
middle bins fill fastest — not by decree, just because more of the sequences land there.
Fig. 8. Every coin-flip sequence is equally likely — so just list them all and count how many land in each head-count bin. Hit step and watch each of n=2's 4 sequences drop into its bin: the split lands 1, 2, 1. Switch to n=3 and step through all 8 sequences — the same process now assembles 1, 3, 3, 1. The middle bins aren't tall by any rule someone wrote down; they're tall because more sequences simply arrive there — that's the whole reason the binomial's middle dominates.

The middle bars are taller for one reason, and it is the single most important idea in this chapter: more sequences land there. Stare at those two rows — 1, 2, 1 and 1, 3, 3, 1 — and something should tug at your memory. It is not that the middle counts are "more likely" by fiat. There is exactly one way to get all heads (HHH), but three ways to get two heads (HHT, HTH, THH). Three sequences against one, so the two-head bar stands three times as tall. That counting of arrangements is where the whole structure comes from, so let's isolate it.

03Why a coefficient shows up

Here is the crux, and it is the exact thing Chapter 2 was built to handle. Fix the count — say 2 heads in 4 flips. To the count, HHTT and THTH and THHT are all the same outcome: two heads, done. Order doesn't matter. But each of those three orderings is a separate sequence in the sample space. So to get the probability of "2 heads" we have to know how many orderings there are. Reorder the tiles below. Every arrangement you make still has two heads, and the counter tallies how many distinct ones exist.

always k = 2 heads — only the order changes H H T T flip 1 flip 2 flip 3 flip 4 found 1 / 6 = C(4,2) the 6 arrangements of 2 heads in 4 flips
tap two tiles to swap positions
reordering can never change k=2 — that's why C(n,k) multiplies the PMF: it counts every order-doesn't-matter tie on the same count.
Fig. 9. Four tiles, fixed faces H H T T — tap one tile, then tap another, and the two swap slots. Reordering never changes the count: every arrangement you can make still has exactly k = 2 heads. But each distinct ordering is a separate arrangement, and the gallery tallies them as you find them — HHTT, HTHT, HTTH, THHT, THTH, TTHH — climbing to exactly C(4,2) = 6 and no further, because that's how many ways exist to choose which 2 of the 4 flips are the heads. That is the reason the binomial's coefficient is a count of order-doesn't-matter ties, not a fudge factor: C(n,k) is literally this tile game, generalized to n flips and k heads.

Order-doesn't-matter is precisely why the combinatorial coefficient appears. That tally — 6 arrangements of 2 heads among 4 flips — is exactly C(4, 2), the n-choose-k you built in Chapter 2: the number of ways to choose which of the flips are the heads. Work it out and it is 4!/(2!·2!) = 24/4 = 6, the same six tiles you just shuffled. Now we need the second half of the recipe: the probability of any one of those arrangements. Here Chapter 5's independence rule does the work, because independent events multiply. Take a specific sequence and read its probability off flip by flip.

5 flips · this order: 3H, 2T H H T H T flip 1 flip 2 flip 3 flip 4 flip 5 independent flips → multiply their factors · × · × · × · × · (nothing multiplied in yet) general shape: p^k · q^(n−k) H → p (heads)   T → q (tails)
click Step to begin multiplying
There are C(5,3) = 10 orders of 3 heads & 2 tails — shuffle a few: each one multiplies out to this same p³q².
Fig. 10. The sequence HHTHT is five independent flips, so its probability is just the factors multiplied: hit Step and watch each flip light up and drop its factor — p for H, q for T — into the product left to right, landing on p³q². Now hit Shuffle: the letters reorder (still 3 heads, 2 tails) and you step through a totally different-looking sequence — yet multiplication doesn't care about order, so it always lands on that same p³q². That's the whole trick behind count-then-multiply: every one of the C(5,3) = 10 arrangements of 3 heads carries this identical probability, so the total is just how many arrangements times this one arrangement's probability.

Notice the beautiful thing. Every arrangement with k successes has the same probability — pᵏ for the k heads times q^(n−k) for the n−k tails — no matter what order they come in, because multiplication doesn't care about order either. With four fair flips, every two-head arrangement is worth (½)²(½)² = 1/16. So the probability of getting exactly k successes is just "how many arrangements" times "the probability of one of them": six arrangements at 1/16 each gives 6/16 = 0.375. Put the two halves together and you have the entire binomial PMF. Let's x-ray it: click a bar and watch it split into its three factors, each with its own job.

P(X=k) = C(n,k) · p^k · q^(n−k) how many arrangements × the k successes × the n−k failures k = number of successes (click a bar) one such arrangement ↓ C(n,k) p^k q^(n−k) multiply the three P(X=k) = …
k = 5 of 10 · P = 0.2461
Never memorise it — read it: how many arrangements, times the k successes, times the n−k failures. Rebuildable from the story every time.
Fig. 11. The binomial PMF, x-rayed. Every bar is the same three-factor product: C(n,k) — how many arrangements of k successes among n slots — times pk, the k successes landing, times qn−k, the n−k failures landing. Click any bar to split it into those three numbers; drag n and p and every bar re-decomposes live. That’s why you never memorise the formula — you read it: arrangements × successes × failures, rebuildable from the story every time.

Read it as a sentence, not a spell: P(X = k) = C(n,k) — how many arrangements — times pᵏ — the k successes — times q^(n−k) — the n−k failures. Three factors, three jobs. If you can say that sentence, you never have to memorize the formula, because you can rebuild it from the story every time. And there is a lovely confirmation waiting: those C(n,k) coefficients aren't new. When p = ½, every arrangement is equally likely. So the whole PMF is just the row of counts C(n,0), C(n,1), …, C(n,n)Chapter 2's Pascal's triangle — divided by 2ⁿ. For four fair flips that row is 1, 4, 6, 4, 1 over 2⁴ = 16. Pull up the triangle and watch a binomial fall right out of a row.

Pascal's triangle (Ch. 2) P(X=k) = C(n,k) / 2ⁿ ÷2ⁿ n=4 k = number of heads
n=4 → row ÷ 16 = the PMF
the row ÷ 2ⁿ *is* P(X=k) — same counts, just rescaled to sum to 1.
Fig. 12. Drag n and two things move together: the gold row lighting up inside Pascal's triangle (Chapter 2's C(n,k) — the count of ways to land exactly k heads in n flips), and that same row landing as bars on the right. At p = ½ every one of the 2ⁿ possible head/tail sequences of length n is equally likely, so dividing each count by 2ⁿ — the total number of sequences — turns raw counts straight into P(X=k), and the shape stays symmetric for every n because C(n,k) = C(n,n−k). Chapter 2 wasn't just counting arrangements — it was quietly building the binomial's shape the whole time.

That triangle is a mirror: C(n,k) always equals C(n,n−k). The chapter told you so. Here is why it must be true. Choosing which flips are the heads is the very same act as choosing which are the tails. Pick the heads and the tails are decided for free, so the two counts can never disagree. Out of five flips, the 10 ways to pick 2 heads are the 10 ways to pick 3 tails.

5 slots, two views of the same choice HEADS 1 2 3 4 5 TAILS 1 2 3 4 5 C(5,2) seen: 1/10 = C(5,3) seen: 1/10 same 10 arrangements, counted twice
2 heads chosen ↔ 3 tails forced
Flip keeps every lit slot exactly where it is — only which count you're building changes.
Fig. 13. Tap any 2 of the five slots to make them heads — the other 3 light up tails on their own, each pair joined by a gold thread. Hit Flip the question: the exact same five slots now answer "which 3 are tails" instead — nothing moves, only the label changes, and you tap the tails row directly while the heads row is forced. Keep retapping, or hit New arrangement, and watch the twin counters climb together — however you cycle through them, C(5,2) seen and C(5,3) seen always read the same number, out of the same 10 total. That's not a coincidence: every way to choose 2 heads out of 5 is a way to choose 3 tails out of 5 — the same pick, wearing two names.

The counting engine and the distribution turn out to be the same triangle seen from two sides. Chapter 2 was quietly building Chapter 9 the whole time. So we now have a formula that reads like a sentence and reduces to Pascal in the fair case. But one real question is still open. It is the one that decides whether this thing is even allowed to call itself a distribution: do all those bars add up to one?

04Is it even a distribution?

Before we trust it, let's earn a guess. Here is a genuinely useful instinct to build: for Binomial(5, 0.3), which count k do you think is the most likely? There is a real tension to feel. A small p = 0.3 pulls the successes down, since each trial fails 7 times out of 10. But the middle counts have more arrangements pulling them up: there are 10 ways to place 2 successes among 5 trials and only one way to place none. Commit to a peak before you look.

.4 .3 .2 .1 0 0 1 2 3 4 5 successes k, out of 5 trials 0 0 0 0 0 0 ↓ p=0.3 pulls low ↑ C(5,k) pulls up peak Binomial(n=5, p=0.3) — P(X=k) ▼ your guess
5 trials, each succeeds with p = 0.3. k = how many of the 5 succeed.
pick a k, 0–5, to place your bet
two forces set the peak: p=0.3 pulls it low, but C(5,k) — the count of arrangements — pulls it toward the middle. The peak sits wherever those pulls balance.
Fig. 14. Binomial(5, 0.3): five trials, each succeeding with p = 0.3, and k counts the successes. Guess which k is most likely, then reveal the true bars. The peak isn't at the low end (where p = 0.3 alone would pull it) or dead in the middle (where the arrangement count C(5,k) peaks) — it lands at k=1, the balance point between a small per-trial weight and a growing number of ways to arrange the successes.

Whatever you guessed, here is the deeper obligation every distribution owes: its probabilities must sum to exactly 1. For a Bernoulli that was trivial — p + q = 1, two bars, done. For the binomial we are summing n + 1 bars, so five trials means six bars. Each bar is a coefficient times two powers, and it is not obvious they land on 1. Except they must, and the reason is one of my favorite little collisions in all of maths. Add up all the bars — Σ C(n,k) pᵏ q^(n−k) — and that sum is literally the binomial theorem's expansion of (p + q)ⁿ. But p + q = 1, so the whole sum is 1ⁿ = 1. Normalization isn't something we check. It is guaranteed by algebra. Step through it.

(p+q)⁴ = q⁴ + 4pq³ + 6p²q² + 4p³q + p⁴ since p + q = 1 :   (p+q)⁴ = 1⁴ = 1 q⁴ 4pq³ 6p²q² 4p³q p⁴ k=0 k=1 k=2 k=3 k=4 P(k successes in 4) = C(4,k) pᵇ q⁴⁻ᵇ Σ C(4,k) pᵇq⁴⁻ᵇ 1.0 0.5 0 0.0000 running total press Next ▸ — expand (p+q)⁴ one term at a time
p = 0.60 · q = 0.40 · (they always add to 1)
a legal distribution must sum to 1…
The dry identity (p+q)ⁿ = 1 and “the bars form a legal distribution” are the same sentence. Nobody checks the bars add up — the algebra already guaranteed it.
Fig. 15. Why the bars must sum to one. Step through the binomial theorem’s expansion of (p+q)⁴: each algebra term is exactly one bar of the distribution, and pouring them all into the tank fills it to 1 — because p+q=1 makes (p+q)⁴=1⁴=1. Normalization isn’t checked; it’s the same statement as the identity. Slide p to see it hold for any p.

Sit with that for a second, because it is the chapter's quiet aha: the binomial theorem is the reason the probabilities sum to one. The same expansion you may have first met as a dry algebra identity is exactly the statement "these bars are a legal distribution." Two ideas that look unrelated turn out to be one idea. Alright — we have built it, read it, and proved it is honest. Time to make it earn its keep by producing an actual number. Let's compute P(X = 3) for Binomial(12, 1/6), the chance of exactly three sixes in twelve dice rolls. Plug it into the sentence, and then confirm it by brute simulation.

n=12 rolls of a die · p=1/6 (rolling a 6) · asking P(X=3) 0 .1 .2 .3 k = number of 6s rolled, out of 12 closed-form PMF 100k simulation law meets the messy world →
n, p, k = 12, 1/6, 3 pmf = choose(n,k) * p**k * (1-p)**(n-k) # now check it against the messy world hits = sum(roll12dice()==k for _ in range(100_000)) sim = hits / 100_000
pmf(3) = –.––––– sim(3) = –.–––––
click run — compute & simulate
Fig. 16. n=12 rolls of a fair die, p=1/6 the chance of a 6 on any one roll — the bars are the Binomial(12, 1/6) law itself, computed once from C(12,k)·pk·(1-p)12-k. The gold bar at k=3 is the question: what's the chance of exactly three 6s? Hit run and the code answers two ways at once — the closed-form pmf(3) ≈ 0.19740, and a fresh 100,000-trial simulation of actual dice rolls, its empirical rate landing as a green line right on the gold bar's cap. Click run again — a new batch of 100k rolls, same landing spot. That's the whole reason the formula gets trusted: the tidy law and the messy simulated world keep agreeing, to the decimal.

The analytic law and the messy world agree to the decimal. There it is: C(12,3)·(1/6)³·(5/6)⁹ ≈ 0.197, and a hundred thousand simulated runs pile up right on top of it. Read the three factors: 220 ways to choose which three of the twelve rolls are sixes, times 1/216 for those three sixes, times about 0.194 for the nine non-sixes. That agreement is the strongest evidence there is that we understand the object and didn't just push symbols around. Now let's feel how the whole shape lives and breathes as we turn its two knobs.

05The shape and its summaries

The binomial has exactly two dials, n and p, and between them they cover a whole zoo of shapes from one formula. Drag p and the hump leans. Below ½ it piles toward the low counts. Above ½ it piles toward the high ones. At exactly ½ it is perfectly symmetric, and that is the pure Pascal row. Drag n and the whole thing climbs, widens, and smooths. Play with both.

P(X=k) — chance of exactly k successes peak 0.00 k=0 k=n mean ≈ 5.0 successes
p=½ → symmetric, mean≈5.0
One formula, two dials: p leans the hump, n smooths it into a hill.
Fig. 17. Two dials sit under this bar chart: drag n (the number of trials) and p (the chance of success on each one) and the whole P(X=k) bar chart redraws on the spot. Pull p left of ½ and the bars pile up over low k (fewer successes); push it right of ½ and they pile up over high k; park it at ½ and the chart turns symmetric — the gold mean line just tracks n×p the whole time. Climb n and the same shape stretches wider and smooths out, spike becoming hill. Same formula, every time — only the two dials change what it draws.

As you slid those dials you were watching the center move, and it moves to a place you can predict without any new work. Remember the atom: one Bernoulli averages p. Stack n of them and, on average, you get n · p successes. So the mean of the binomial is np, and its variance is npq, the atom's pq times n. Twelve dice rolls at 1/6 each therefore average 2 sixes, with a variance of 12 × 1/6 × 5/6 ≈ 1.67. (The clean reason the pieces just add like that is linearity of expectation. It gets its own full treatment in Chapter 15; for now, trust the atoms.) Watch the fulcrum ride to np as you change the dials.

k — number of hits (out of n) the atom · one flip (n = 1) 0 1 p = 0.35   q = 0.65 atom:  mean p = 0.35   var pq = 0.23 ↓ × 10 atoms, summed independently ↓ stack: mean np = 3.50  var npq = 2.28
10 atoms stacked → np=3.5 npq=2.3
That's why the binomial's center is np: n trials, each contributing p on average — the atom's mean, times n.
Fig. 18. Drag n (how many atoms get stacked) and p (each atom's own chance of a hit). The single flipped atom, bottom left, always has mean p and variance pq — that never changes. What changes is the big histogram: its fulcrum rides to np and its spread band widens with the variance npq — drawn at its natural ±1 SD width, np ± √(npq), because summing n independent copies of the same atom just multiplies its mean and its variance by n. No integral, no new formula — the binomial's center and spread are the atom's own summary, paid out n times.

The fulcrum slid to np and I asked you to trust it. An expert does not compute that mean the hard way. The hard way sums the whole PMF: Σ k·C(n,k)pᵏq^(n−k), a real grind. The easy way adds n atom-means, each worth p, and stops. Five atoms each worth 0.3 add to 5 × 0.3 = 1.5, and the grind returns that same 1.5. Run both roads and watch them land on the same number.

THE GRIND THE SHORTCUT your guess 3.0 np = 4.00 Σ over every k · weight by k 1 atom = p drop n copies of p Σ = 0.00 Σ = 0.00 work: 0 mul+add work: 0 adds
guess np, then press race
Both roads land on the same np. Only one had to grind through the whole pmf to get there.
Fig. 19. Two roads reach the very same mean. Set n and p, slide your guess for np (the cyan line), then hit race. The grind walks every one of the n+1 pmf bars, weights each by k, and piles the terms k·C(n,k)pᵏqⁿ⁻ᵏ into a slowly-climbing column — the literal definition of the mean. The shortcut just drops n identical atom-means, each equal to p, into a second column. Both columns rise to the same gold np line — at the defaults n=8, p=0.50 that's np = 4.00 — yet the work badges tell the real story: the grind burns about (n+1)(n+2) = 90 multiply-and-adds while the shortcut needs just n = 8 additions. Drag n to 10 and the gap blows open to 132 vs 10. That gulf is what "the mean falls out for free" means: the mean of a sum is the sum of the means, so a count's average is just its atoms' averages added up — no combinatorics required.

So the center sits at np. Twenty rolls of a die, a sixth of them sixes, so expect about 3.3 sixes. The spread is √(npq), which for those same twenty rolls comes out at about 1.7. Two numbers, straight from the atom, no integral in sight. And finally, let's not forget what this whole machine is for. The binomial answers real questions, and the ones we usually ask aren't "exactly k" but "at least k" — at least 8 heads in 10 flips, at least 3 defects in a lot. That is just Chapter 8's idea again: an event on the count is a window of bars, and its probability is their sum. Slide the window and read the answer off.

Binomial(n=10, p=0.5) — each bar is P(X=k) 0 .25 0 1 2 3 4 5 6 7 8 9 10 k = heads out of 10 flips a b the window sums to P(X ≥ 8) 0.055 3 bars summed Ch 8 summed a window of curve-area for a continuous event — same move here: sum the bars the window encloses.
P(X≥8) = 0.055 (3 bars)
Drag the gold handle(s) — every bar the window encloses lights up and joins the sum.
Fig. 20. Eleven bars, one per outcome of ten coin flips — each bar's height is P(X=k), exactly as Ch 8 drew a bar or a curve for any random variable. Drag the gold handle a (or toggle to a<X≤b and drag both) and watch the window slide: every bar it encloses turns green and joins the running total on the right. "At least 8 heads" was never a single number to look up — it's P(X=8)+P(X=9)+P(X=10), the same window-sum move Ch 8 used for continuous events, just standing on the count axis instead of a curve.

The events world never left. It just moved onto the count axis, exactly as Chapter 8 promised. So this one distribution gives us the chance of at least so many successes, at most so many, or anything between two thresholds. That covers every practical question about repeated trials, and it all comes from one formula built out of one atom. Let's step back and see where this puts us.

06You are here — and the fork

Take a breath, because we have just reached a genuine landmark. The binomial is the hub of the whole distribution family. It is the first real, named distribution, built with our bare hands from the Bernoulli atom and Chapter 2's counting. Nearly every distribution left in this book is reachable from that one node. And the road out is governed by a single question: which regime are you in? Watch the same binomial fork two ways. Push it toward many trials at a moderate p and the jagged bars fuse into a smooth bell, which is the Normal. Push it toward rare events instead — p → 0 while you hold the expected count λ = np fixed — and it collapses into the lopsided spike of the Poisson. Same source, two destinations.

THE BINOMIAL — n trials, chance p each n=12 p=0.50 λ=n·p=6.0 λ=6 k — number of successes tail → ∞
the atom — could tip either way
One regime question forks the hub: common-and-many fuses into the bell (Ch 10); rare-and-many collapses into the Poisson spike (Ch 11). Same bars, two futures.
Fig. 21. Same 12-trial, p=0.50 binomial, one fork. Click big n, mod p and the bars barely move — they're already hugging the smooth Normal curve, because a moderate-p binomial converges to the bell fast. Click rare, hold λ instead and, even holding the same expected count λ=6, the bars sag lower at the peak and stretch a long tail to the right — that's the Poisson signature. Same question, two limits — Ch 10 and Ch 11 are what each button previews.

That fork is the next two chapters. It is also one of the widest conceptual jumps in the whole book, so we'll spend real care on it. Chapter 10 takes the common-and-many road and discovers that the bell curve is nothing but the binomial's large-n limit. That is the first and cleanest instance of the Central Limit Theorem. Chapter 11 takes the rare-and-many road to the Poisson. But before we drive down either road, fix your position on the map: the atom you can now build in your sleep, and the hub it stacks into.

aha — stack the atom, count it: that's the whole family's branch point Normal (large n) Poisson (n→∞) …more (geo, etc.) 2 counting 5 independence 8 random variable Bernoulli the atom P(X=1) = p one flip YOU ARE HERE Binomial (n, p) n Bernoullis, summed the spine so far, feeding the hub it forks from
Hover or tap the gold hub to trace the rung back to what it's built from.
tap the rung: trace what it stands on
Bernoulli, stacked n times and counted — the one atom every law ahead forks from.
Fig. 22. The course spine so far: counting (Ch 2), independence (Ch 5) and the random variable (Ch 8) all feed one atom — a single Bernoulli flip, P(X=1)=p. Stack n of them and count the successes, and you get the Binomial — the gold hub marked YOU ARE HERE, the first named distribution in the book. Hover or tap the hub: the rung lights gold, the three dashed threads snap taut back to their sources, and the faint forks on the right — Normal, Poisson, and the rest still ahead — glow just enough to show they all fork from here. One atom, stacked and counted, is the whole family's branch point.

There's our rung, lit gold. We started this chapter holding a single yes/no and a promise. We leave it able to build the binomial from scratch, read its PMF as a sentence, prove it sums to one, compute any probability it can answer, and place it at the branching point of the entire family. One atom, stacked n times and counted: that is the hub, and from here the tree opens up. Next we take the first road out of it and watch those bars melt into a curve. Turn the page.

iolinked.com
Written by Ajai Raj