For seven chapters we asked one kind of question: does this thing happen? The card is a spade or it isn't. The test comes back positive or it doesn't. Every object we handled was an event — a subset of the sample space, something that is either in or out. But look at what we kept wanting instead. Not whether a coin came up heads, but how many heads in ten flips. Not whether the bus is late, but how long we wait. Every time, we reached past the yes/no for a number. This chapter hands us that number, and one line says why it pays. A hundred flips is 2¹⁰⁰ sequences nobody will ever write down. "# heads" is 101 honest numbers. That is compression, and the rest of the course lives on it. The move itself is almost disappointingly small: we attach a number to every outcome. A function from outcomes to the reals is a random variable. Make one, and the event {2 heads} stops being a clump of sequences and simply becomes the value 2. Give every value its probability and the unwieldy sample space folds up into one compact object, a distribution. So we will build the machine that eats an outcome and emits a number. We will watch several outcomes pool their probability into one bar. We will meet the CDF, a running total that has already answered every "less than" question at once. And we will split the world into discrete values you sum and continuous values you integrate. Along the way we defuse the most common trap in all of continuous probability: for a continuous variable the density is not a probability, because a point has zero width. One small move, a number on each outcome, and probability turns into something you can add, average, and predict.
01From outcomes to numbers
Let's stand on the exact rung Chapter 7 left us on. Everything we built there handled events — "the card is a spade," "the test is positive" — pure yes-or-no subsets of the sample spaceΩ. And we admitted a hunger that machinery could not feed: we kept wanting a number. So here is the whole move, and it is worth watching rather than taking on faith. Take the honest sample space of three coin flips: all eight equally likely sequences, HHH through TTT, each carrying probability 1/8. Now attach a number to each one, X = the count of heads. The instant you do, something quietly enormous happens. The event {exactly 2 heads} was the three sequences HHT, HTH, THH. Now it stops being a clump of outcomes and simply becomes the value 2. Drag each outcome and drop it onto its number.
Ω = 8 outcomes of 3 flips. X counts the Heads in each.
placed 0 / 8 — drag one down
a whole subset of Ω can share one value — that collapse is the hinge of the whole second half.
Fig. 1. The random variableX = the number of Heads, laid bare. The sample space Ω holds all 8 outcomes of three coin flips; drag (or click) each chip onto its head-count on the value line. Watch what happens to the event {2 heads}: the three outcomes HHT, HTH, THH — a whole subset of Ω — fold down onto the single point 2. That is the hinge of the entire second half of the course: an event (a set of outcomes) becomes a number (one value of X), because a subset lands on one point. Every distribution you meet from here on is built on exactly this collapse.
A random variable is a function. That is the sentence to hold: a rule Ω→ℝ that takes an outcome and returns a real number. Feed it HTH and it returns 2. Feed it TTT and it returns 0. Being exact about what the object is matters here, because the word "variable" is quietly misleading. X is not a number, and X is not a variable in the algebra sense. The "random" part is only this: chance chooses the input, so the output is chancy too. And the collapse you just watched — a whole subset of Ω landing on a single point of the number line — is the hinge of this chapter, and honestly of the entire second half of the course. Here is the machine, laid bare. Drop an outcome in the top and watch a number fall out the bottom.
X is a machine: feed it a 3-flip outcome, it emits how many heads. Same rule, different input → different number — that's why it's a variable.
click an outcome to feed X
Fig. 2. The random variable X, laid bare as a machine. Its domain is Ω — the eight equally-likely three-flip outcomes; its codomain is ℝ, the real line. Feed it one outcome and it emits exactly one number: the count of heads. Notice the dots — HHT, HTH, THH all fall on the same 2, so a whole clump of outcomes collapses to one point (that pooling is the next figure's distribution). The machine never changes; only what you drop in does. That's the whole idea of a "random variable": it isn't a number at all, it's a fixed rule Ω→ℝ — and because the input is chosen by chance, the output is too.
The number you attach is your choice, not a fact about the coins. Most courses skip that, and it matters. On the same eight-outcome Ω you could just as easily define X = the count of heads, or Y = 1 if the first flip is heads else 0, or Z = the length of the longest run. Hand all three the outcome HTH and X reports 2, Y reports 1, and Z reports 1. Same underlying randomness, three different random variables. That is because a random variable is a lens you point at the outcome. Which number you read off is a modelling choice, and it is yours to make. Swap the lens and watch the same outcome report a different value.
X(ω) = 1 heads out of 4
same ω, three different numbers — the number is your rule, not a fact about the coins.
Fig. 3. One fixed outcome ω — four coin flips, T-T-T-H — sitting still on the sample space Ω of all 16 possible sequences. Click X, Y, Z to swap the rule you apply to that same ω: X counts the heads, Y asks only whether flip 1 was heads, Z reports the longest same-face run — and the highlighted coins plus the readout change instantly, even though ω itself never moves. Hit new ω to try another outcome; the three rules still disagree. A random variable is nothing more than one of these rules — a function from Ω to a number — so the number you get was never a property of the coins. It's a property of which function you chose to apply.
A random variable is any rule you invent, and its distribution is that rule read backwards. You have watched three ready-made rules fire, but you have never built one yourself. So take the eight three-flip outcomes and this time choose the number each one earns. Drop any value onto any outcome. The instant two outcomes share a value their weights pool — two outcomes at 1/8 each hand that value 2/8 — and a distribution assembles from your own mapping. That is the move that ends the mystery.
Predict: give every outcome the SAME number. How many bars will the distribution show?
click an outcome above ↑
—
pick a guess, then press reveal
Any rule Ω→ℝ is a random variable
Fig. 7 folded a rule the book chose (X = #heads)
here you invent the rule — any number, any outcome
the bars are never anything but pooled preimages
Fig. 4. Ω still holds the same 8 equally likely three-flip outcomes — but this time you write the rule. Predict what happens if every outcome gets the same number, then press reveal and watch all 8 fold onto one bar of height 8/8 = 1. Now click any outcome and step its value with + / −, or slam a preset: all different spreads the 8 outcomes into 8 bars of 1/8 each; randomize pools them however chance lands; back to #heads rebuilds Fig. 7's own 1, 3, 3, 1 out of 8. Nothing here is fixed to counting heads — a random variable is any function Ω→ℝ you invent, and its distribution is just that function read backwards: collect every outcome that lands on a value, and pool its 1/8.
The hurdle here is a specific one, and you already crossed it years ago without noticing. Going from 3 + 5 = 8 to x + 5 = 8 was a leap. The first line is arithmetic on numbers you know. The second introduces a symbol that stands in for a number you don't yet know, and here that symbol resolves to 3. A random variable asks you to make the same leap again, one storey higher. X is a symbol that stands in for a rule, and behind that rule sits a whole distribution of possible values, each with its own weight. If that felt like a real gear-shift in your head, good: it is supposed to, and naming the shift is half of getting past it. Sit with the jump for a beat.
3+5 always equals 8 — no surprise
In arithmetic, the letter x is a mask over ONE hidden number — solve for it and the mystery's over. A random variableX LOOKS like the same kind of letter, but it's not hiding one number — it's a rule tied to a whole distribution of outcomes, each with its own probability. That's why X feels slippery: it's the same jump as 3+5=8 → x+5=8, taken one storey higher.
Fig. 5. Click X + 5 = ?. In arithmetic, x hides ONE fixed number — plug it in and you're done. Flip the toggle and X stops being a hidden number: it becomes a rule (roll a die, read the face) with a whole distribution behind it — six equally likely outcomes, each with probability 1/6 — so X+5 is a whole shifted distribution too, not a single answer. The little staircase says it plainly: this is the exact same kind of leap as solving for x, just taken one storey higher.
Hold onto that. X is a rule with a distribution behind it, not a single value, and everything else in this chapter is us learning to read that distribution. But first, the question you should be asking: why bother? We could already describe those eight outcomes perfectly well by listing them. So what does bolting a number onto each one actually buy us? What it buys is the reason random variables exist at all, and it is spectacular.
02The great compression
Here is the payoff, and it is a Chapter 1 idea come home to roost. Back then we said the deep reason probability exists is compression. You don't track 10²³ gas molecules; you track a couple of dials that summarize them. The random variable is that same move, made exact. Watch what happens to the bookkeeping as you add flips. With n flips there are 2ⁿ individual sequences. At n = 100 that is 2¹⁰⁰, a number with thirty-one digits, more sequences than there are atoms in your body. Nobody will ever list them. But the random variable "number of heads" takes only the values 0, 1, 2, … , n, which is just n + 1 of them. So at n = 100 the whole intractable mess collapses to 101 honest numbers. Slide n and watch the two counters tear apart.
2^8 ≫ 9 values
That's why random variables exist — a distribution compresses the chaos, it isn't a longer list.
Fig. 6. Slide n, the number of coin flips. The top meter is 2ⁿ — every distinct sequence of heads and tails; the bottom meter is n+1 — the possible values the count of heads can take. At n=1 the two bars are equal (2 sequences, 2 values — nothing has compressed yet). By n=100 the top bar has swallowed the meter (2¹⁰⁰ ≈ 1.27×10³⁰, a 31-digit number) while the bottom bar is barely a sliver (only 101 values, 3 digits). The fixed panel below shows why the values stay so few even in principle: at n=3 the 8 sequences HHH…TTT collapse into just 4 possible counts, in the ratio 1-3-3-1. That's why random variables exist — a distribution is a compression of the chaos, not a longer list.
That gap between 2ⁿ and n + 1 is the entire reason the random variable earns its keep: it exists so you never have to enumerate. But here is a fair question. Where did the probability go when we folded all those sequences down? It didn't vanish. It pooled, and pooling is the one thing to really understand in this section. When several outcomes share a value — HHT, HTH, THH all map to 2 — their individual probabilities add up into that value's total. Each of those three sequences carries 1/8, so P(X = 2) = 3/8. The distribution is just Ω folded along the lines of equal X, with probability piling up in each fold. Watch the outcomes drop into their bins and the bar heights build from the pooled weight.
drop the first outcome to begin
Ω has 8 equal paths; X = heads count folds several onto one bar — the pooled weight IS the bar's height.
Fig. 7. Ω holds 8 equally likely coin-triples (3 flips, each path worth 1/8). Click drop next outcome and watch each one slide down its dashed fold-line into the bar for its X, the number of heads. X=0 and X=3 each catch one lonely path; X=1 and X=2 each catch three different paths folding onto the same bar. That's the whole mechanism: a bar's height is never anything but the probability of every outcome that collapsed onto it, pooled — the PMF is Ω folded along lines of equal X.
And now that you've seen how the bars are built, let's test whether you can feel their shape. This is a predict-then-reveal, so commit before you peek. For four fair flips, what does the histogram of "# heads" look like — flat? A single spike? A hump? Four flips allow five counts, 0 through 4, so five bars are up for guessing. Lock in a guess and reveal it. Then — this is the good part — drag n upward and watch the shape settle into something you will be seeing for the rest of this book.
X = heads in 4 flips — guess, then reveal
your guess: bell
Fig. 8.X is the count of heads in 4 coin flips — a random variable: a number that depends on chance. Pick the shape you expect, then reveal the real bars: 1, 4, 6, 4, 1 out of 16, peaking at 2 heads. That jagged little shape has a name — the binomial distribution. Now drag n, the number of flips, way up: the same rule (count the heads) keeps producing bars, and as outcomes multiply those bars stop looking jagged and fuse into a smooth hump — the bell curve waiting at the far end of this course.
That growing hump is the binomial distribution taking shape. Over four fair flips its bars run 1/16, 4/16, 6/16, 4/16, 1/16, peaking at two heads. Further downstream it will smooth into the bell curve, but we are getting ahead of ourselves. The point for now is that a distribution has a shape you can reason about. That means it is a real object worth studying carefully. So let's pin down exactly what that object is.
03What a distribution is
A distribution sounds like a heavy word, so let me deflate it right away: it is exactly two things and not one thing more. First, the values the variable can take — its support, the 1, 2, 3, 4 along the bottom. Second, the probability of each value — the bar heights. That's it. For a discrete variable, that list of value-and-weight is called the probability mass function, or PMF. "Mass" is exactly the right word, because each value carries a lump of probability mass. One iron law binds all those lumps together, and it is an old friend: Chapter 3's axiom that P(Ω) = 1. Since some value always happens, the bars must sum to exactly 1. Four bars of 0.25 each would qualify, and so would 0.4, 0.3, 0.2, 0.1. Drag any bar up and watch the others give way to keep the total pinned.
drag a bar — the rest must give way
drag any bar's top (or click inside it) — the others shrink or grow so the total never leaves 1
Fig. 9. Meet the PMF — the probability mass function of a random variable X: nothing more than a list of its possible values paired with how likely each one is, written P(X = x). Drag any bar's top (or click inside it) and watch the other three shrink or grow to compensate — the total pinned at the top stays 1 no matter what you do. That isn't a coding trick: the events {X=1}, {X=2}, {X=3}, {X=4} are disjoint and between them cover every outcome that can happen, so together they are the whole sample space Ω. Chapter 3's axiom P(Ω) = 1 doesn't stop applying just because we relabelled outcomes with numbers — it's still in force, just spread across the values of X. Hit extreme and pile everything onto one value: the rest are forced to exactly zero, not "close to zero." Some value always happens; the bars can only ever redistribute certainty, never create or destroy it.
Figure 3 pointed one sample space at three different rules and got three different shapes. Now run the arrow backwards: two completely different experiments can pour into the same bars. Count the heads in two flips and the values 0, 1, 2 come out weighted 1/4, 1/2, 1/4. Spin a four-sector spinner marked 0, 1, 1, 2 and the weights are the identical 1/4, 1/2, 1/4. One distribution, two sources, and the bars cannot tell you which one produced them. A pmf keeps how much probability landed on each value and throws the outcomes away on purpose.
predict: could you name the experiment?
the bars forget on purpose — that's why one distribution can be reused for a thousand unrelated problems.
Fig. 10. Predict first: from the finished bars alone, could you name which experiment made them? Then pick coins, spinner, or urn and hit run — three completely different back-stories (two flips counted, a labelled spinner, a ball drawn from an urn), and every one builds the exact same three bars, 1/4, 1/2, 1/4. Hit which one made this? and the widget refuses to answer — it can't, because the histogram never recorded which story it came from, only how much probability landed on 0, 1, and 2. That deliberate forgetting is the whole point: a distribution is what's left of an experiment after you throw away everything except the numbers, which is exactly why the same 1/4, 1/2, 1/4 can be recycled across a thousand unrelated problems.
Every legal distribution lives under that constraint: non-negative bars that total one. Now here is a reassurance, because it can feel like we have left the events world behind entirely. We haven't. Every event you cared about before is still right there, just re-expressed on the number line. "At least three heads" is the event {X ≥ 3}, and its probability is nothing but the sum of the bars inside that window. Over four flips that window holds two bars, 4/16 and 1/16, for 5/16 in total. Slide a window across the values and watch the enclosed probability add itself up.
P(1≤X≤3) = 7/8 = 0.875
at k=3 there's nowhere higher to go, so "X≥3" and "X=3" land on the same bar — the window's just narrow.
Fig. 11. Drag either gold handle — or click a bar, a preset, or a slider — to slide the window across X = 0, 1, 2, 3. Every bar caught inside turns green and its fraction joins the running sum on the right: 1 ≤ X ≤ 3 catches three bars and reads 7/8; drag both handles onto 3 and you're left with the single top bar, P(X=3) = 1/8 — the same value "at least 3" would give, since 3 is as far right as X goes. Nothing new is being computed here, only added: an event is still just a subset, now drawn as a window of bars on the number line instead of a cluster of coin sequences.
{X = k} is only a nickname for a subset of Ω, and this figure proves it. A window of bars is easy to shade, but where did the outcomes go? Point at any value and its preimage lights back up: the exact outcomes that map there. Build an event like {X ≥ 2} or {X even}, watch its whole subset glow, then count those outcomes the old Chapter 3 way. Over three flips {X ≥ 2} is four sequences out of eight, and the bars agree: 3/8 + 1/8 = 4/8. The number-line answer and the counted-outcomes answer always match.
your guess: 1 — hit reveal
{X=k} isn't "the k-th outcome" — it's every outcome that maps to k. Count them in Ω or sum the bars; same number either way.
Fig. 12. Pick an event on the right — {X = 2}, {X ≥ 2}, {X even}, or {X < 1} — slide your guess for how many of the 8 outcomes it contains, then hit reveal. The default guess of 1 for {X=2} is a trap: reveal shows 3, because HHT, HTH, THH all map to 2 — the event is a subset, not a single outcome. Try {X even} and the same trap runs deeper: it isn't 1 or 2, it's 4 — TTT plus HHT, HTH, THH — because 0 is even too. Whichever event you pick, the outcomes that light up gold in Ω and the bars that light up gold on the number line are counted separately and always land on the same number: that's P(X ∈ A) = |X−1(A)| / 8 read two ways. Switch to {X ≥ 2} and click show complement too: the remaining outcomes glow blue as {X<2}, and 4/8 + 4/8 = 1.00 — Chapter 5's complement rule, running on values exactly as it ran on outcomes.
So the number line didn't cost us the events. It gave us a cleaner place to ask about them. "Between 1 and 3," "at least 3," "exactly 2" are all just windows of bars now. But summing a window every single time is tedious. There is a smarter object that does the summing once, ahead of time, for every window at once. Meet the accumulator.
04The running total: the CDF
Here is a genuinely clever repackaging. Instead of storing the height of each bar, store the running total: for every value x, the probability that X lands at or below it, F(x) = P(X ≤ x). This is the cumulative distribution function, or CDF. Over three flips, F(1) covers 0 heads and 1 head, so F(1) = 1/8 + 3/8 = 4/8. The way to feel it is as an accumulator. Sweep a line from left to right across the values, and F is simply everything the line has passed so far, piling up. It starts at 0 on the far left, with nothing accumulated yet. It climbs in a step at each value, jumping by exactly that value's mass. And it arrives at 1 on the far right, because by then it has swept up all the probability there is. Drag the sweep line and watch the staircase build.
F(0.5) = P(X≤0.5) = 0.00
aha — F(x) has already answered every "X ≤ x" question at once. No summing left to do — just read the height.
Fig. 13. Same random variable, two panels. Left: the bars, each one the probability P(X = x) that outcome x occurs. Right: the staircase, F(x) = P(X ≤ x) — "the chance X lands at or below x." Drag the gold sweep line left to right (or click a bar): as it crosses each value, that bar lights up on the left, and on the right the staircase jumps up by exactly that bar's height, climbing from 0 to 1. Nothing is ever re-summed — each jump is just the next bar's mass, added once and kept forever.
That staircase is a small marvel: it has already answered every "less than" question you could ask, all at once. And it answers every range question with a single subtraction. The probability that X falls in (a, b] is just how much the accumulator climbed between them: P(a < X ≤ b) = F(b) − F(a), the vertical gap between two heights on the staircase. Over three flips the window (1, 3] catches 2 heads and 3 heads, and F(3) − F(1) = 1 − 4/8 = 4/8. No re-summing a window of bars. Read two numbers and subtract. Watch the range light up on the bars and the same answer appear as a gap on the CDF.
drag the a / b handles on the bars, or pick a window below.
a b
F(2)−F(0) = 0.750
aha — the shaded bars and the staircase gap are always the same number. A range costs one subtraction, not a re-sum.
Fig. 14. Three fair flips, X = number of heads. On the left, drag the gold a and cyan b handles (or tap a preset) to pick a window of bars — the event a < X ≤ b. On the right, the same a and b land as two dots on the CDF staircase, and the green bracket is the vertical gap between their heights. Every time: the shaded bars' total and the bracket's height are the identical number, because P(a < X ≤ b) = F(b) − F(a) — read two heights off the staircase and subtract, instead of re-adding a window of bars.
You just read F(b) − F(a) off the staircase, but notice the small print: that subtraction quietly leaves a out. Ask for P(1 ≤ X ≤ 3), reach for F(3) − F(1), and you fall short by one whole bar. The missing piece is the jump the staircase makes at 1: that step's height is exactly P(X = 1), which over three flips is 3/8, so the honest total is 4/8 + 3/8 = 7/8. On a staircase ≤ keeps the endpoint. < drops it.
Asked: P(1 ≤ X ≤ 3). Commit an answer, then reveal.
left endpoint
right endpoint
your answer: —
jump — drag the violet ◆: riser at X=1 is 0.375 = P(X=1).
Fig. 15. Three fair flips, X = number of heads. Asked P(1 ≤ X ≤ 3), commit an answer and reveal: the gut's F(3) − F(1) = 0.500 is only the open window P(1 < X ≤ 3) — the closed answer is 0.875, because it must also count the jump at 1, P(X=1) = 0.375. Toggle either endpoint between ≤ and < and watch that value's riser light up or vanish in both the bars and the staircase; drag the violet ◆ onto any step to read its jump height straight off as P(X=k). The riser is the point mass — which is exactly why F(b) − F(a) quietly drops the left endpoint.
Two views of one truth. The bars tell you the mass at each value. The staircase tells you the mass up to each value. Each one is a single subtraction or a single difference away from the other. Everything so far has lived in a world of countable, separated values you can point at. But some numbers don't come in separated lumps. A waiting time can be 3 seconds, or 3.1, or 3.14159… — a smooth continuum with no gaps. That world needs one careful adjustment, and it hides the subtlest trap in the whole chapter.
05Discrete or continuous
Random variables split into two families, and the split is cleaner than it first looks. A discrete variable takes countable, separated values — number of heads, roll of a die, customers in a queue. Those are the kind you can list with gaps between them: a die gives 1 through 6 and nothing in between. A continuous variable takes every value in an interval — a height, a temperature, a wait time — an unbroken smear with no next value along. Here is a quick gallery to calibrate your eye before we go further. Sort each example into its family.
Click a card, then click its bin.
tap a card, then tap its bin
discrete = you could count every outcome
continuous = a value hides between any two
Fig. 16. Four everyday numbers, two families. #heads-in-ten-flips and a die face are discrete — you could list every value they can take: 0,1,2,…,10. Bus wait time and a student's height are continuous — between any two readings, say 4.1 and 4.2 minutes, another value always hides. That fork is why one family gets a probability mass you sum, and the other gets a probability density you integrate.
Now the beautiful part: these two worlds aren't really two ideas. They are one idea seen at two resolutions. For a discrete variable, the probability in a range is a sum of masses — Σ. For a continuous one, it is an integral under a curve — ∫. And the integral is just what a sum becomes when you let the bars get infinitely thin and close all the gaps. Chop a unit interval into 10 bars of width 0.1 and the curve appears. Make it 1000 bars of width 0.001 and bars and curve are indistinguishable. Same shaded region, same "add up the probability inside the window," with the sigma smoothed into the integral sign. Toggle between the two over the identical range.
n=8: Σ off by 0.002 from ∫
the integral is just the sum with the gaps closed — same accumulation, higher resolution.
Fig. 17. The same range, x ∈ [1,3], read two ways. In Σ discrete, the density is chopped into n bars and you add up bar-area, Σ f(xᵢ)Δx — drag bars up and the gap between the bar-tops and the faint target curve visibly closes, and the running total creeps toward the exact answer. Flip to ∫ continuous and the bars vanish into the solid curve itself — the shaded area ∫₁³ f(x)dx is exact, no approximation left. Same accumulation, same shaded range, only the resolution changed: that's why the integral is the sum with the gaps closed.
Hold that picture — Σ and ∫ are the same accumulation — because it makes the trap that follows survivable. In the continuous world, ask an innocent question: what is the probability that a wait time is exactly3.000… seconds, on the nose? The honest answer is zero. Not "tiny" — exactly zero. A single point has no width, and probability in the continuous world is area. The window from 2.9 to 3.1 has width 0.2 and carries real area. Shrink that window to width 0 and the area goes with it, no matter how tall the curve is. Watch a probability window shrink toward a single point and see its probability drain to nothing.
P(window) ≈ 0.9600
the height at x₀ never moves — still 0.2000 even at w = 0. Area = height × width, and width → 0 kills the area, however tall the curve is there.
Fig. 18. Drag half-width w toward 0, or hit → a point: the shaded window narrows and its area — the probability — drains to 0.0000, while the curve's height at x₀ never moves (still 0.2000). Area = height × width, and one exact value has zero width — so P(X = x₀) = 0 for any single continuous value, no matter how tall the curve is there.
Let that land, because it is the source of the single most common misconception in continuous probability. If P(X = x) = 0 at every point, then whatever the height of that curve is, it cannot be a probability. And it isn't. This is the fix I promised in the intro, and it is worth stating flat. The curve for a continuous variable is a density, written f(x), and a density is not a probability. It is probability per unit x — a rate. Its height can be greater than 1 with no contradiction at all: a density of 2 across an interval of width 0.5 gives probability 2 × 0.5 = 1. You only get a real probability when you multiply by a width: probability ≈ density × dx. In other words, probability is area. Drag the interval's width and watch the height sit perfectly still while the area — the actual probability — grows and shrinks.
Waiting time is uniform on 0–0.5 s, so the density is flat at f = 2 (a probability rate). Drag the interval's width — the height never budges; the area is the probability.
Why a density can top 1 — f = 2 is probability per unit x, a rate. Multiply it by a width to get a real probability. Area only reaches 1 across the whole support — never more.
height 2.0 fixed · area = P = 0.40
Fig. 19. A uniform waiting time on 0–0.5 s has a flat density of f = 2 — and yes, a density can sit above the dashed f = 1 line. Drag the interval's width: the gold height marker never moves, because f is a rate (probability per unit x), not a probability. The real probability is the area = height × width, and it only reaches 1 across the entire support — which is exactly why a density is allowed to exceed 1.
There is the whole confusion, dismantled. height ≠ probability. area = probability. The density is the height whose only job is to give the right area once you multiply by a width. One last tidy-up bonds the two worlds together. The discrete CDF was a staircase that jumped at each value. The continuous CDF has no jumps to make. It is a smooth ramp, and its slope is precisely the density: steep where probability piles up, flat where it is sparse. A ramp that climbs 0.2 over a width of 0.1 has slope 2, so the density there is 2. Density and CDF are one object and its rate of change. Drag along the ramp and read its steepness back as the density beneath.
steep patch — density piles up
Drag in the panel above: the ramp's steepness at any point is the density directly beneath it — that's not a coincidence, it's the definition.
Fig. 20. Drag anywhere in the panel above and a gold handle rides the ramp — the continuous CDF, F(x) — while a guide line drops straight to the densityf(x) beneath it, lighting up the matching bar. Where the ramp leans hard (the middle stretch) the density bar is tall; where it barely climbs, the bar is short — the ramp's steepness is the density, read straight off. Now slide steps: a blocky staircase — the jumps you'd get chopping the range into K coarse slices, one per "outcome" — tightens onto the smooth ramp as K grows, and every jump shrinks toward nothing. That's the whole reveal: in the continuous world there are no jumps left to make, only a ramp — and its slope, everywhere, is the density.
So the same two objects carry across both worlds: a way to say "how much mass here," and a way to say "how much mass up to here." Only the machinery under them switches, from sum to integral, from jump to slope. That symmetry is going to save us enormous effort downstream, because it means every trick we learn on one side has a mirror on the other. Let's step back and see where this leaves us on the map.
06You are here
Take a breath and place this chapter on the family tree, because we have just done something structural. For seven chapters we lived in the world of events, measures on subsets of Ω. This chapter promoted that world onto the number line. Attach a number to each outcome, and probability becomes something you can add, average, and predict. The random variable is the trunk the entire second half of the course grows out of. Every named distribution ahead is just a particular shape of this one object. Find our rung, lit gold.
hover a rung to trace what fed in
Every stage behind you funnels into one gold idea below.
Hover — or click — the four rungs, the gold trunk, or any branch ahead.
Fig. 21. The spine you've already walked: counting → the measure → conditioning → the Bayes flip — hover any rung to trace what it fed in. All of it lands on one gold trunk: the random variable, a function that attaches a number to every outcome (Ω→ℝ). Every branch on the right — Binomial, Normal, Poisson, Exponential, even the summit at the CLT — is a shape this same object can take. That's why this chapter is structural: probability just moved onto the number line, and nothing ahead is a new idea, only a new costume for this one.
And now the first step down that trunk, taken deliberately. We have been talking about complicated random variables, counts over many flips, but every one of them is built from the simplest possible one. Ask the most basic question a random variable can answer: did a single yes/no event happen? Assign it 1 for success and 0 for failure, with probability p of the one. For a fair coin p = 0.5, so each of the two values carries 0.5. That two-valued atom is the Bernoulli random variable, the hydrogen atom of this whole subject. And here is the thread into the next chapter. Take n independent Bernoulli trials, add them up with Chapter 2's n-choose-k counting, and you have built the binomial — the first real distribution, the hub the family tree forks from. See the atom, and the hub it stacks into.
flip the stack to sample K
n Bernoullis, summed — that sum has a name: Binomial.
Fig. 22. Click flip atom and one Bernoulli(p) fires a single 0 or 1 — that's the entire random variable, no more machinery than a weighted coin. Click flip stack (n) and n independent copies fire together; counting how many landed on 1 is exactly the counting problem Ch 2 taught you to solve with n-choose-k, now weighted by p per success and q=1−p per failure — C(n,k)·pᵏ·qⁿ⁻ᵏ. Watch that count land on the histogram: that shape is the Binomial, and every bar is one value the counting formula already knew how to count. This is the hydrogen atom of probability, and the hub the whole family — Poisson, Normal, all of it — forks from next.
That is the road ahead. We spent seven chapters learning to measure whether something happens. In this one we learned to attach a number to it and fold the chaos into a distribution. Next we start naming the distributions, beginning with the single yes/no coin and the count of n of them. Once we can name them, we can predict cases we have never seen. Turn the page.