A random variable assigns a numerical value to each possible outcome of a random process, turning chance events into numbers that can be added, averaged, and analysed using the full toolkit of mathematics. Despite the name, a random variable is neither random (in the sense of being unpredictable in its definition) nor strictly a variable in the ordinary algebraic sense β it is formally a function.
Roll a die. The outcome is a physical event β a die landing showing a certain face. A random variable is the rule that converts that outcome into a number you can actually do arithmetic with. For a standard die, the natural random variable X just assigns X(outcome) = the number of dots showing: 1, 2, 3, 4, 5, or 6.
A discrete random variable takes distinct, separate values β like a die roll (1 through 6) or the number of heads in 10 coin flips (0 through 10). A continuous random variable can take any value in a continuous range β like a person's exact height, or the exact time until a radioactive atom decays.
A random variable X is formally a function X : Ξ© β β, mapping outcomes in a sample space Ξ© to real numbers, such that for every real number x, the set {Ο β Ξ© : X(Ο) β€ x} is a measurable event (has a well-defined probability). This technical measurability condition ensures that questions like "what is the probability X is less than 5?" always make sense.
For a discrete random variable, the probability mass function p(x) = P(X = x) gives the exact probability of each possible value. For a continuous random variable, individual exact values typically have probability zero, so instead a probability density function f(x) is used, where probabilities correspond to areas under the curve: P(a β€ X β€ b) = β«βα΅ f(x) dx.
The expected value E[X] is the long-run average value of X over many repetitions, weighted by probability:
For a fair six-sided die, E[X] = (1+2+3+4+5+6)/6 = 3.5 β notably, a value the die itself can never actually show, illustrating that the expected value is a long-run average, not a predicted single outcome.
Variance, Var(X) = E[(XβE[X])Β²], measures how spread out the values of X tend to be around the mean. The standard deviation, Ο = βVar(X), expresses this same spread in the same units as X itself (rather than squared units), making it more directly interpretable.
Two random variables are independent if knowing the value of one gives no information about the other. Remarkably, linearity of expectation, E[X+Y] = E[X]+E[Y], holds true always β even when X and Y are not independent β making it one of the most useful and frequently applied facts in all of probability theory.
Rigorously, following Kolmogorov's axiomatic framework (see the Probability entry), a random variable is a measurable function X : (Ξ©, F, P) β (β, B), where F is a Ο-algebra of events on the sample space, and B is the Borel Ο-algebra on β. The distribution of X is the probability measure it induces on β, defined by pushing forward P through X. This framework allows expected value to be defined uniformly, for both discrete and continuous cases (and mixtures of the two), as a single Lebesgue integral: E[X] = β«_Ξ© X dP.
The n-th moment of X is E[XβΏ]; the mean is the first moment, and variance is related to the second moment. The moment generating function M(t) = E[e^(tX)], when it exists, uniquely determines the entire distribution of X and provides a powerful technical tool: moments can be extracted by repeated differentiation of M(t) at t=0, and sums of independent random variables correspond to simple products of their moment generating functions β often making otherwise difficult calculations about sums tractable.
Probability theory distinguishes several different, technically inequivalent notions of a sequence of random variables "converging": convergence in distribution (the weakest, underlying the Central Limit Theorem), convergence in probability (underlying the weak Law of Large Numbers), and almost sure convergence (the strongest, underlying the strong Law of Large Numbers). Careful distinctions between these modes of convergence are essential for correctly stating and proving the major limit theorems of probability theory.
Multiple random variables considered together form a random vector, described by a joint distribution capturing not just each variable's individual (marginal) behaviour but also how they relate to and depend upon each other β quantified by covariance and correlation. This framework generalises naturally to the multivariate normal distribution and underlies essentially all of modern multivariate statistics, machine learning, and quantitative finance.