Random Variables, Expectation and Variance
A number decided by chance, summed up by its expectation (the long-run average) and its variance (how far it typically strays).
Needs a step first: 4
A random variable attaches a number to each outcome, such as the score on a die. Its expectation is the average over many repeats, and its variance measures the spread. Expectation is always linear, , even when and depend on each other, but variances add only for independent variables. These two numbers run through distributions, the central limit theorem, entropy and every loss function in machine learning.
Where it shows up: Training a model minimises an expected loss, and stochastic gradient descent works because a random mini-batch gradient has the true gradient as its expectation.
How to hold it: By hand, until automatic
Use linearity of expectation, , and the sum rule for independent variances automatically, since they sit inside nearly every argument about data and models.
What knowing it looks like
- Compute the expectation and variance of a discrete random variable from its table.
- Use and .
- Use linearity of expectation to find an average without working out the whole distribution.
Test yourself
Let be the score on one fair die. Find and . Then find the mean and variance of , and of the total of two independent dice.
Show the worked answer
Needs a step first: 4
Learn it with an AI
Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.
Be my maths tutor. I'm learning "Random Variables, Expectation and Variance" (Core tier): A number decided by chance, summed up by its expectation (the long-run average) and its variance (how far it typically strays).
I already know: Conditional Probability.
Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away.
Finish by testing me with this: Let $X$ be the score on one fair die. Find $E[X]$ and $\operatorname{Var}(X)$. Then find the mean and variance of $2X+1$, and of the total of two independent dice.
Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.Needs first
Picks up from the children's map: Averages and Spread
Leads to
- Binomial, Poisson and Normal DistributionsThree shapes chance takes again and again: counts of successes, counts of rare events, and measurements clustered around an average.Core · Probability & Statistics
- Correlation and RegressionMeasuring how closely two quantities move together, and fitting the straight line that best predicts one from the other.Core · Probability & Statistics
- Markov ChainsA random process hopping between states, where the next step depends only on the current state and not on how it got there.Undergraduate II · Probability & Statistics
- Statistical Mechanics and EntropyTemperature, heat and entropy explained by counting microscopic states: each state of energy has probability proportional to .Undergraduate II · Physics
- Information and EntropyEntropy measures the average surprise of a random outcome, in bits: the shortest average code length.Undergraduate I · Optimisation & Information
- Stochastic Gradient Descent and AdamGradient descent using the gradient of a small random batch instead of all the data, plus momentum and per-parameter step sizes (Adam).Frontier · Optimisation & Information
On the way to
Recommended
- MIT 6.1200J Mathematics for Computer ScienceMIT OpenCourseWare · CourseMIT's 2024 course on proofs, number theory, graphs, counting and discrete probability, with lecture videos, notes and problem sets.
- Mathematics for Machine LearningDeisenroth, Faisal and Ong (Cambridge University Press) · BookA free book that gathers exactly the linear algebra, vector calculus, probability and optimisation machine learning uses, then applies them to regression, PCA and classification.
- Seeing TheoryBrown University · InteractiveA visual introduction to probability and statistics in which you flip coins, draw samples and fit lines in the browser; complete and ad-free, with a Chinese version.
- Harvard Stat 110: ProbabilityJoe Blitzstein, Harvard University · CourseJoe Blitzstein's Harvard probability course: lecture videos, about 250 practice problems with solutions and a free online textbook, strong on intuition and story proofs.
- Information Theory, Inference, and Learning AlgorithmsDavid MacKay · BookMacKay's book connecting entropy, coding, Bayesian inference and neural networks, free to read online and still the one recommended for information theory with intuition.
- 宋浩老师官方宋浩(山东财经大学) · Videos · 中文Full university courses in calculus, linear algebra and probability by a Shandong University of Finance and Economics lecturer, clear and good-humoured; a new calculus series came out in October 2026.