Worked examples — Random variables (discrete and continuous)
This page is a drill ground. The parent note built the machinery — PMF, PDF, expected value. Here we push that machinery through every kind of input it can meet, so no exam question or real dataset ever surprises you.
Before we start, one promise: every symbol you see was defined in the parent note. If you want a refresher on any of them, the relevant Expectation and Variance and Gaussian Distribution notes are one click away.
The scenario matrix
Think of a random-variable problem as a machine with inputs. The inputs can be nice (a clean die) or nasty (a degenerate constant, a zero-probability point, an infinite tail). The matrix below lists every case class — every fundamentally different kind of input — that this topic can throw at you.
| # | Case class | What makes it special | Example that hits it |
|---|---|---|---|
| C1 | Finite discrete, uneven weights | PMF values differ; must weight the sum | Ex 1 (loaded die) |
| C2 | Countably infinite discrete | Sum runs to ; needs a series | Ex 2 (geometric wait) |
| C3 | Degenerate RV | All probability on ONE value | Ex 3 (constant "random" variable) |
| C4 | Continuous, bounded support | PDF nonzero only on | Ex 4 (uniform interval) |
| C5 | Zero-probability point | for continuous — the classic trap | Ex 5 (exact-value question) |
| C6 | Continuous, infinite tail | Support is all of ; tails must decay | Ex 6 (Gaussian window) |
| C7 | Mixed / limiting behaviour | Binomial with large → looks Gaussian | Ex 7 (limit crossover) |
| C8 | Real-world word problem | Translate English → RV first | Ex 8 (spam filter) |
| C9 | Exam twist: transformed RV | Compute , not | Ex 9 (variance as ) |
Each example below is tagged with the cell it covers. Together they fill the whole table.
Ex 1 — Loaded die (C1: finite, uneven weights)
Forecast: guess before computing — will be above or below the fair-die average of ? (The six is favoured, so bet above.)
Step 1 — Turn "twice as often" into numbers. Let each ordinary face have probability . The six has . Why this step? The parent note's normalization rule () is the only equation that pins down the unknown . Everything must sum to 1 because something happens.
So the PMF is and .
Step 2 — Apply the discrete expected-value formula. Why this step? weights each value by how often it appears in the long run — the six, appearing twice as often, pulls harder.
Step 3 — Arithmetic.
Verify: ✓ matches our forecast. Sanity check on the PMF: ✓.
Ex 2 — Waiting for the first success (C2: infinite discrete)
Forecast: with heads only 1-in-3, do you expect the first heads early or late? (Late — guess around 3.)
Step 1 — Build the PMF. To need exactly flips you get tails then a head: Why this step? Flips are independent, so probabilities multiply (parent note's binomial logic). This is the geometric distribution — a countably infinite discrete RV.
Step 2 — Check it normalizes over an infinite sum. Why this step? For infinite support we must confirm the geometric series converges to 1 — this is case C2's whole point: "sum to 1" now means "the series adds to 1".
Step 3 — Expected value. Using the known geometric-series result : Why this step? We need a series, not a finite sum. The identity is the tool that answers "how many trials on average?".
Verify: matches the forecast (rare event → wait trials). Unit sanity: is a count of flips, dimensionless, positive ✓.
Ex 3 — The constant "random" variable (C3: degenerate)
Forecast: if it's always 5, what's the average? What's the variance?
Step 1 — Expected value. Why this step? The formula still applies; there's just one term. A constant is a perfectly legal (degenerate) random variable — the "randomness" is zero.
Step 2 — Variance. Why this step? Variance measures spread. No spread ⇒ variance — this is the boundary case every distribution collapses to when uncertainty vanishes (see Expectation and Variance).
Verify: , . This is the limiting case of any distribution as its spread shrinks to nothing — a useful mental anchor.
Ex 4 — Uniform on an interval (C4: continuous, bounded)
Forecast: the interval is wide; the sub-interval is wide. Guess .

Step 1 — Density. Why this step? Uniform means constant density; the height is forced to so the total area is 1.
Step 2 — Probability as area. Why this step? For continuous RVs probability = area under (look at the shaded blue strip in the figure), because at any single point.
Step 3 — Expected value (midpoint). Why this step? Symmetry: equal density on both sides ⇒ the balance point is the centre.
Verify: matches forecast. lies inside and at its centre ✓.
Ex 5 — The zero-probability trap (C5)
Forecast: careful — this is the classic mistake. Is equal to ?
Step 1 — Exact-value probability. Why this step? An integral over an interval of zero width is zero — geometrically, a line segment has no area.
Step 2 — Boundary probability. Why this step? At and beyond the density is , so there is no area to accumulate. This also shows — the whole distribution lives inside .
Verify: Both answers are . Consistency check: was whether or not we include the endpoints, precisely because endpoints contribute ✓.
Ex 6 — Gaussian window (C6: infinite tail)
Forecast: the famous "68–95–99.7" rule — guess about 68%.

Step 1 — Write the PDF. Why this step? This is the Gaussian form from the parent note; the tails stretch to but decay fast enough that the total area is still exactly 1 (case C6: infinite support, decaying tail).
Step 2 — Standardize to a -score. Let . Then maps to . Why this step? Every Gaussian is a stretched/shifted copy of the standard . Rescaling by turns "within one " into "within ", which we can read off one universal table.
Step 3 — Read the area. Why this step? This is the fixed area under the standard bell between (shaded orange in the figure). It never changes — that's why the 68% rule works for any Gaussian.
Verify: ✓ matches forecast and the empirical rule. See Central Limit Theorem for why Gaussians appear so often.
Ex 7 — Binomial marching toward Gaussian (C7: limiting behaviour)
Forecast: the mean should be . Within of — is that roughly one ? Guess "a bit more than 68%".
Step 1 — Mean and variance of Binomial. So . Why this step? (each flip adds ) and come from summing independent Bernoullis (see Bernoulli and Categorical Distributions).
Step 2 — Invoke the Gaussian limit. For large , Binomial . The window is exactly . Why this step? By the Central Limit Theorem, a sum of many independent trials becomes bell-shaped — this is case C7, where a discrete RV is well-approximated by a continuous one.
Step 3 — Use the one-sigma area.
Verify: , ; the window is one standard deviation, giving ✓, matching the forecast "a bit more than 68%" (exact binomial is ; the Gaussian estimate is close).
Ex 8 — Spam filter word problem (C8: real-world translation)
Forecast: expected flagged . "At least 2" — probably high, guess .
Step 1 — Identify the RV. Let = number flagged. Independent flags with fixed ⇒ . Why this step? The English "each independently, count the successes" is the definition of a Binomial — always translate words to an RV first.
Step 2 — Use the complement. Why this step? "At least 2" over many terms is easier as (the two small cases). counts which single email is flagged.
Step 3 — Compute. And .
Verify: matches ""; ✓. Connects to Maximum Likelihood Estimation (estimating from flagged counts).
Ex 9 — Exam twist: variance via (C9: transformed RV)
Forecast: a fair die has variance . The loading concentrates weight at 6, slightly changing spread — guess "a little under 3".
Step 1 — Compute (a transformed RV). Why this step? Variance needs , and is a function of . The rule — the law of the unconscious statistician — lets us reuse the same PMF without finding the distribution of .
Step 2 — Arithmetic.
Step 3 — Subtract the square of the mean. From Ex 1, , so . Why this step? The shortcut avoids computing term by term — algebraically identical but faster.
Verify: , close to but not equal to the fair-die ; loading raised the spread by pulling weight to the extreme value 6. Variance is positive ✓.
Recall Quick self-test
Why is for a continuous RV but not for a discrete one? ::: A continuous RV spreads probability over an interval as area; a single point has zero width ⇒ zero area. A discrete RV places lumps of mass on specific points. For , what is on the interval? ::: . Binomial : mean and ? ::: mean , . What tool turns "within one " into a table lookup? ::: The -score .
See also: Joint and Conditional Distributions, Sampling Methods, Information Theory.