Lecture 3: Discrete Random Variables and Expectation
EECS 126 (UC Berkeley) · Spring 2026 · January 27, 2026
We transition from events to random variables — functions that assign numerical values to outcomes — and develop the key tools of expectation, linearity, LOTUS, and variance.
Random Variables and PMFs
A (discrete) random variable is a function that assigns a real number to each outcome . We write for the probability of the event .
The probability mass function (PMF) of a discrete random variable is the function defined by
The PMF satisfies , where denotes the set of all values taken by (the support).
Let be a random variable with for . Define . Then takes values in and
In general, if , then .
Popular Discrete Distributions
: a single coin toss.
: number of successes in independent Bernoulli trials.
Note: by the binomial theorem, confirming this is a valid PMF.
: number of trials until the first success.
The geometric distribution is the discrete analog of “waiting time.”
: models the number of arrivals in a fixed interval.
The Poisson is the limiting distribution of as , and arises naturally in modeling rare events and arrival processes.
Alice and Bob play a match: the first to win a game wins the match. If there are 10 consecutive draws, the match is declared drawn. Each game independently: , , .
Let be the duration (number of games). Then for :
since the first games must be draws and the -th decisive. For : (all 9 games drawn, match ends).
. Using for , in the limit of no cap on draws: .
Expectation
The expected value (or mean) of a discrete random variable is
provided the sum converges absolutely (i.e. ).
For any random variables (not necessarily independent) and constant :
No independence assumption is needed. This is the single most useful property of expectation.
For an event , the indicator is
Observe that , so .
A full flight has passengers with assigned seats, but every passenger ignores their assignment and sits in a uniformly random seat. What is ?
Let . Then . The are not independent (if and passenger 1 is in their seat, passenger 2 must be too). But linearity of expectation does not require independence:
Regardless of the number of passengers, on average exactly 1 person sits in their own seat.
LOTUS (Law of the Unconscious Statistician)
If is a discrete random variable and is any function, then
More generally, for a function of several random variables:
The name reflects that one can compute directly from the distribution of , without first finding the distribution of .
Independence of Random Variables
Random variables and are independent (written ) if their joint distribution factors into the product of the marginals:
If , then
By LOTUS and independence:
The key step is factoring the joint PMF into marginals (by independence), which allows separating the double sum into a product of single sums.
The converse is false. does not imply . The condition is called uncorrelation, which is strictly weaker than independence. As an exercise, construct dependent random variables that are uncorrelated.
Tail Sum Formula
Let be a random variable taking values in . Then
Starting from the definition of expectation:
The key step is writing to introduce a double sum, then swapping the order of summation (Tonelli’s theorem ensures this is valid for nonnegative terms). Geometrically, this corresponds to “counting vertically then horizontally”: instead of weighting each column by its height , we sum across rows , each contributing .
Intuition for the tail sum. Think of as the total area under the “staircase” of the survival function . Each unit step at height contributes to the total. This is the same idea as computing the area under a curve by integrating horizontally rather than vertically.
Variance
The variance of measures the spread of around its mean:
The standard deviation is .
An equivalent computational formula (often easier to use):
Expand the square using linearity:
Note that is a constant, so and .
For constants :
Adding a constant shifts the mean but does not change the spread. Scaling by scales the variance by (and the standard deviation by ).
Let . Then , so
Coming up next lecture: covariance , variance of sums, and the beginning of continuous random variables.