M06.5 · Discrete random variables
M06.5 L1 · Core 4 lessons · about 100 min Live · in review
Part of M06 Probability I in the Mathematics track.
An experiment’s outcome is a pair of dice, a string of heads and tails or a path through pegs, but the questions we ask are about numbers: the total, the count, the bin. A random variable is the function that turns each outcome into a number. These four lessons build its probability mass function by gathering outcomes, its cumulative distribution function as a staircase that also draws samples, and the distribution of a sum of two independent variables by adding products along the diagonals of a table, which is how a Galton board grows Pascal’s triangle.
What you need first. Sample spaces, events and the axioms (M06.1), counting with n choose k (M06.2.3), and independent events (M06.3.4) for the last lesson. The code uses Python dictionaries and sets (P01.6), fractions.Fraction and a little NumPy.
Lessons
A random variable is a function of the outcome M06.5.1 25 min
A random variable gives a number to every outcome of an experiment: the sum of two dice, the heads in three flips, the bin of a Galton board ball. See why statements such as X = 3 are events, and build random variables in Python as dictionaries.
The probability mass function M06.5.2 25 min
Gather the outcomes that give each value and you get the probability mass function, one bar per value. Build it for the sum of two dice, a Galton board, a squared variable and flips until the first head, then set it beside a simulation.
The cumulative distribution function M06.5.3 25 min
Stack the bars of a PMF and you get the CDF, a staircase from 0 to 1 that jumps at each value. Read interval probabilities, medians and quantiles off it, and use it to draw samples from any PMF, the way a language model picks its next word.
Independent random variables and their sums M06.5.4 25 min
Two random variables are independent when every joint probability is a product. Then the PMF of their sum comes from adding products along the diagonals of a table, a discrete convolution: two dice again, and one more row of a Galton board, which is Pascal’s rule.
The interactive
M06.5-X1 · Galton board. Choose the number of rows and drop one ball or a hundred. The last ball’s path is the outcome and its bin is the value; the bin shares grow into a histogram beside the exact PMF bars, and a tilt control sets the chance of bouncing right. It lives in The probability mass function.