Mathematical Foundations

random variable

/ RAN-dum VAIR-ee-uh-bul /

A random variable is a number whose value is not settled yet because it depends on chance. Before you roll a die, 'the number that comes up' is a random variable — you know it will land between 1 and 6, but not which one. Once the die stops, the random variable takes a definite value. So it is less a single number than a placeholder for 'whatever number this uncertain process will spit out.'

The point of giving uncertainty a name is that you can then do math with it: ask what value it tends to take on average, how much it bounces around, and how likely each outcome is. Random variables come in two flavors. Discrete ones take separate, countable values, like a die roll or the number of emails you get tomorrow. Continuous ones can take any value in a range, like a person's exact height or the temperature at noon.

Machine learning is shot through with random variables, because the world it learns from is uncertain. The label of a yet-unseen image, the next word a language model will generate, the noise in a sensor reading — all are modeled as random variables. Treating quantities this way lets a model express not just a guess but a degree of confidence, and lets us reason cleanly about error, risk, and surprise. A useful caution: calling something a random variable does not mean it is truly 'random' in some cosmic sense — only that we are choosing to model it as uncertain given what we know.

Let X be the result of one die roll. X is a discrete random variable that can equal 1, 2, 3, 4, 5, or 6, each with probability 1/6. Let Y be tomorrow's high temperature in your city — a continuous random variable that could be 18.3°C or 18.34°C or anything nearby. Naming X and Y lets us compute their averages and spreads.

X (a die roll) is discrete; Y (a temperature) is continuous — both are placeholders for an as-yet-undecided number.

A random variable is not a fixed number with a label — it is the whole bundle of possible values together with their probabilities. The list of those probabilities is its probability distribution, the next idea to learn.

Also called
随机变量隨機變量隨機變數随机变数