M06.9 · Joint, marginal and conditional distributions
M06.9 L1 · Core 4 lessons · about 100 min Live · in review
Part of M06 Probability I in the Mathematics track.
Two random variables read off the same experiment are tied together, and their separate PMFs cannot show how. These four lessons put the pair on one table, the joint distribution, and read three things from it: each variable’s own distribution by summing out the other, the distribution of one given a value of the other by rescaling a row, and independence as every cell being the product of its margins. The last lesson does the same with a density over the plane, where probability is a volume and sums become an integral inside an integral.
What you need first. Discrete random variables, their PMFs and independent pairs (M06.5), conditional probability and the law of total probability (M06.3), and densities and integrals (M06.6, M04.5 to M04.7) for the last lesson. The code uses fractions, itertools and Counter, NumPy arrays with axis sums and broadcasting, pandas.crosstab and scipy.integrate.dblquad.
Lessons
Joint distributions as tables M06.9.1 25 min
Two random variables on the same outcomes have a joint PMF: one probability for every pair of values, laid out as a table. Build the course’s table from three coin flips, read any event about the pair as a sum of cells, and count the table in NumPy and pandas.
Marginals: summing out a variable M06.9.2 25 min
The PMF of one variable is hidden in the joint table: add each row for X and each column for Y. Why that is the law of total probability, why the margins cannot rebuild the table, and how summing out a hidden variable gives the mixture models of machine learning.
Conditional distributions and independence M06.9.3 25 min
Learning the value of X picks out one row of the joint table; rescaled to add to 1, that row is the conditional PMF of Y, with its own mean. The product rule, Bayes’ rule for PMFs, and independence as every row rescaling to the same PMF.
Joint densities M06.9.4 25 min
For two continuous variables the joint table becomes a surface with volume 1 beneath it, and the probability of a region is the volume above it: an integral inside an integral. Marginals, conditionals and independence carry over from the table, worked on a square and a triangle.
The interactive
M06.9-X1 · Joint table explorer. The course’s 3 by 3 joint table as shaded cells, with the two marginals as bars along its edges. Pick a row or a column to condition on and watch that slice rescale into a conditional PMF with its mean marked; a toggle swaps in the independent table with the same marginals, where every slice rescales to the same PMF. It lives in Conditional distributions and independence.