The Timpson Lyceum · Discrete Math (2025)
Probability, Random Variables, and Expectation - Lecture 16 (Discrete Math)
Overview
This lecture introduces random variables and expectation, the bridge between a raw sample space and the numerical quantities we actually care about. Despite the name, a random variable is neither random nor a variable — it is simply a function whose domain is the sample space. Once we can attach a number to every outcome, we can ask for the probability that the function takes a given value, and we can ask what value we should expect it to take on average. The lecture builds intuition through dice, coin flips, and gambling-style spinner games, connects the binomial coefficient to the probability of getting a fixed number of heads, defines independence of random variables, and closes with the definition and key properties (linearity) of expected value.
Key Concepts
Sample space. A sample space is an ordered pair where is the set of all possible outcomes and is the probability function assigning each outcome a number in . The probabilities of all outcomes must sum to . For one fair die, and for every outcome.
Random variable. Given a sample space and any set , a function is called a random variable. The only requirement is that its domain is — it assigns something to every outcome. The defining mental model: random variable = function.
Real random variable. The case we care about almost always: a function that maps every outcome to a real number — just like the probability function itself. (A non-real example: a function that maps a coin-flip string to the set of positions where heads occur. The output need not be a number; output sets can be anything.)
Probability that a random variable equals a value. Writing means the probability of the event "the outcome maps to ": This replaces the old event-based language: instead of defining a separate event for "rolled a 7," we define one random variable and talk about . For most real numbers (e.g. , , ) this probability is , since no outcome maps there.
Building new random variables from old ones. Random variables can be combined like functions. For two dice with rolls written , let and . Then , defined by , is the familiar "sum of the dice" random variable.
Coin flips and the binomial connection. Flip a coin times; the sample space consists of all length- strings of H's and T's. For a fair coin each string has probability . If counts the number of heads, then the number of strings with exactly heads is , so: For an unfair coin with and , each specific string with heads and tails has probability , so: This is exactly a term of the binomial theorem, , with and . Since and , the full sum equals — i.e. the probabilities of getting heads add to , as they must.
Independent random variables. and on the same sample space are independent provided that for all values : equivalently — knowing gives no information about . For two dice, (first die) and (second die) are independent, but the sum is not independent of (knowing the first die changes the distribution of the total).
Expected value. For a real random variable on , the expected value is the probability-weighted average of its outputs: Equivalently — and usually easier to compute — sum over the values the variable can take: where all but finitely many terms vanish because for most . (Going from the first form to the second is a regrouping of terms by output value, valid because addition is commutative and associative and because a real random variable always outputs a real number to group by.) Expectation answers "what would the long-run average be over a huge number of trials?" — e.g. one fair die has .
Linearity of expectation. For real random variables and a constant :
- combined: .
This holds regardless of independence, mirroring the linearity of limits and derivatives. It makes scaling trivial: since one die has , rolling dice has expected total .
Products are different. holds only when and are independent. It does not follow from linearity (compare: the derivative of a product is not the product of derivatives — it needs the product rule).
Worked Example
Unfair-spinner gambling game. A spinner lands on with probabilities . The payout random variable pays you the number you land on (in dollars): . What is the fair price to charge per spin? Compute .
Apply the value-weighted definition , then substitute:
So the game is worth about $1.88 per spin; charging $2 turns a steady profit. Note the intuition trap: a similar "odd pays $20, even pays $10" spinner feels like a $15 game but actually has E(Y) = 20\cdot\tfrac12 + 10\cdot\tfrac14 + 20\cdot\tfrac18 + 10\cdot\tfrac18 = \text{\} 16.25$ — higher than intuition suggests.
Proof sketch — linearity . Starting from the definition and using that :
Summary
- A random variable is a function on the sample space ; a real random variable maps outcomes to . The name is misleading — nothing is random or variable about it.
- lets one random variable replace many separately-defined events.
- For coin flips, (with for a fair coin); summing over all gives by the binomial theorem.
- Random variables are independent when ; conditioning then changes nothing.
- Expected value is the long-run average; for one fair die it is .
- Expectation is linear () for any random variables, but requires independence.