Random variable
A random variable is not what its name suggests. Pafnuty Chebyshev, according to George Mackey, was the first person to think systematically in terms of random variables, and even he was working with something far more precise than the word "random" implies. At its core, a random variable is a mathematical function, one that maps outcomes in a sample space to values in a measurable space. A coin toss lands on heads or tails; those outcomes get assigned the numbers negative one and one. The randomness lives in the world. The variable is just the translation.
That gap between the everyday meaning of "random" and its formal mathematical meaning is where the real story begins. Why would mathematicians build an entire architecture of functions and measure spaces just to talk about dice rolls and coin flips? And what happens when you try to extend these ideas beyond numbers, into graphs, sentences, and shapes? The answers reach into graph theory, machine learning, and the deepest foundations of probability itself.
Coin tosses and dice rolls are the standard entry points, but they obscure what a random variable actually is. In the formal language of measure theory, a random variable is a measurable function from a probability measure space, called the sample space, to a measurable space. The sample space holds every possible outcome. The random variable translates those outcomes into values, usually real numbers.
Consider a simple coin toss. The sample space contains two outcomes: heads and tails. A random variable can map heads to negative one and tails to one. Nothing in that mapping is itself random. The function is fixed. What varies is which outcome actually occurs.
For dice, the sample space for two dice is the set of all pairs of numbers drawn from one through six. The random variable maps each pair to its sum. The function itself is deterministic. The uncertainty lies entirely in which pair gets chosen.
This distinction matters for a precise reason. The purely mathematical analysis of random variables is, by design, independent of interpretational questions about what probability means or where randomness comes from. Whether probability reflects physical chance, personal belief, or measurement error, the mathematics proceeds the same way. Chebyshev's insight was that this translation, from fuzzy phenomena to precise functions, made systematic analysis possible.
Height and number of children both describe a randomly chosen person, but they behave very differently as random variables. Number of children is discrete: it can only take non-negative integer values. Its probabilities can be catalogued one by one using a probability mass function, which assigns a probability to each individual value.
Height is continuous. A continuous random variable is one whose cumulative distribution function is continuous everywhere, meaning there are no gaps where a single value absorbs a positive chunk of probability. In fact, for an absolutely continuous random variable, each individual exact value must have probability zero. Probability is only positive over intervals, and it is captured instead by a probability density function.
A spinner that can point in any horizontal direction gives a clean example. Map each direction to its bearing in degrees clockwise from North, and the random variable takes values in the interval from zero to three hundred sixty, with every part of the range equally likely. The probability density of this variable is one divided by three hundred sixty. Any exact angle has probability zero. Any range of angles has a positive probability proportional to the size of that range.
Between discrete and continuous lies a third case: the mixed random variable. Consider a coin flip paired with a spinner. If tails, the variable equals negative one. If heads, it takes the value the spinner lands on. There is a positive probability of exactly negative one, which is discrete behavior, but the remaining probability is spread continuously over a range. Its cumulative distribution function is neither discrete nor everywhere continuous. More generally, every probability distribution on the real line is a mixture of a discrete part, a singular part, and an absolutely continuous part.
Once a random variable is defined, the natural questions become: what value does it tend to take, and how far from that center does it typically wander? The expected value, denoted with a specific mathematical symbol and also called the first moment, captures the average. It can be thought of intuitively as an average obtained from an infinite population, where each member is a particular evaluation of the random variable.
Knowing the average is rarely enough. The variance and standard deviation answer the follow-up question: how far from the average do the values typically stray? Together, these quantities characterize much of what matters about a distribution in practice.
Behind these practical tools lies a more ambitious mathematical program called the generalized problem of moments. For a given class of random variables, the goal is to find a collection of functions whose expectation values fully characterize the distribution. Moments can be taken not only for real-valued random variables but also for real-valued functions of more general random variables. A categorical variable that takes the values red, blue, or green has no natural numeric moments, but a function that equals one when the variable is green and zero otherwise does. The expected value of that indicator function is perfectly well defined.
Two random variables can have identical distributions and yet differ in important ways. They may be independent of each other, or they may be correlated. Sorting out the difference requires placing both variables on the same underlying probability space, where joint behavior, covariance, and dependence can be properly defined.
Statistics traditionally restricts the term random variable to the real-valued case, where expected values, variances, and cumulative distribution functions all make natural sense. The formal definition from measure theory, however, imposes no such restriction.
A random variable can take values in any measurable space: Boolean values, complex numbers, vectors, matrices, sequences, trees, sets, shapes, manifolds, or functions. These more general objects go by the name random elements, and they are particularly useful in graph theory, machine learning, natural language processing, and related fields where the data structures of interest are not numbers.
A random word, for instance, can be represented as a random integer indexing into a vocabulary, or as a random indicator vector whose length equals the vocabulary size and whose single positive entry identifies the word. A random sentence of a given length becomes a vector of random words. A random graph on a given number of vertices becomes a matrix of random variables whose entries specify the adjacency matrix.
A stochastic process is a random function of time. A random field is a random function on any set, typically time, space, or a discrete set. Beneath all of these extensions lies the same foundational structure: a measurable function from a probability space to a target space with a well-defined notion of measurability. When the target space carries a topology, the natural choice for the sigma-algebra over that space is the Borel sigma-algebra, generated by the collection of all open sets.
Two random variables can be equal in at least three distinct senses, and the differences matter more than they might first appear. Equality in distribution is the weakest: variables X and Y are equal in distribution if they share the same cumulative distribution function, even if they are defined on entirely different probability spaces. Two random variables with equal moment generating functions are guaranteed to be equal in distribution, though the moment generating function only exists for distributions with a defined Laplace transform.
Almost sure equality is stronger. Variables X and Y are equal almost surely if the probability that they differ is exactly zero. For most practical purposes in probability theory, almost sure equality behaves like genuine equality.
The practical stakes become clear with an example involving four real random variables, A, B, C, and D, all defined on the same probability space. If A and B are equal almost surely, then their covariances with any third variable D are equal. If A and C are only equal in distribution, their covariances with D can differ, even though A and C look identical when examined in isolation. The shared probability space is what allows covariance and correlation to be defined at all; once two variables are related to others on that space, distributional equality is no longer enough to preserve their joint behavior.
Beyond equivalence lies the question of convergence. A major thread in mathematical statistics concerns what happens as sequences of random variables grow long: the law of large numbers and the central limit theorem are the most prominent results in this vein, each describing a different sense in which averages and sums of many random variables settle toward predictable limits.
Common questions
What is a random variable in mathematics?
A random variable is a measurable function from a probability measure space, called the sample space, to a measurable space. Despite its name, the term in its mathematical definition refers neither to randomness nor variability; it is a precise function that translates outcomes into values, usually real numbers.
Who first thought systematically in terms of random variables?
According to George Mackey, Pafnuty Chebyshev was the first person to think systematically in terms of random variables.
What is the difference between a discrete and a continuous random variable?
A discrete random variable takes values in a finite or countably infinite set and is described by a probability mass function. A continuous random variable has a continuous cumulative distribution function with no gaps, and each exact value has probability zero; probabilities are assigned to intervals using a probability density function.
What is a mixed random variable?
A mixed random variable is one whose cumulative distribution function is neither purely discrete nor everywhere continuous. It can be realized as a mixture of a discrete part and a continuous part, and every probability distribution on the real line is more generally a mixture of a discrete part, a singular part, and an absolutely continuous part.
What is the expected value of a random variable?
The expected value, also called the first moment, is the mathematical formalization of a random variable's average value. It can be understood intuitively as an average obtained from an infinite population whose members are particular evaluations of the variable.
What is the difference between two random variables being equal in distribution versus equal almost surely?
Two random variables are equal in distribution if they share the same cumulative distribution function, even across different probability spaces. They are equal almost surely if the probability that they differ is exactly zero. Variables equal in distribution but not almost surely can have different covariances with a third variable defined on the same probability space.
All sources
11 references cited across the entry
- 1BookMathematics for machine learningMarc Peter Deisenroth — Cambridge University Press — 2020
- 2BookIntroduction to ProbabilityJoe Blitzstein et al. — CRC Press — 2014
- 3JournalHarmonic analysis as the exploitation of symmetry – a historical surveyMackey — July 1980
- 5BookThe Practice of StatisticsDaniel S. Yates et al. — Freeman — 2003
- 7JournalA Modern Introduction to Probability and StatisticsFrederik Michel Dekking et al. — 2005
- 8BookIntroduction to Probability and Stochastic Processes with ApplicationsL. Castañeda et al. — Wiley — 2012
- 9BookProbability and MeasurePatrick Billingsley — Wiley — 1995
- 10BookIntroduction to ProbabilityDimitri P. Bertsekas — Athena Scientific — 2002
- 11Economics 245A – Introduction to Measure TheoryDouglas G. Steigerwald — University of California, Santa Barbara