Random Variable

A random variable is a variable whose possible values are outcomes of a random or uncertain process, each associated with a probability — the number of heads in 10 coin flips, a customer's time-to-purchase, tomorrow's temperature. The name is somewhat misleading to newcomers: a random variable isn't random in the sense of being unpredictable or lawless, it's a formal mathematical object that maps every possible outcome of a random process to a number, which is precisely what allows the full machinery of probability theory and statistics — expected value, variance, distributions — to be applied to something as conceptually fuzzy as "an uncertain outcome."

Random variables split into the same discrete-versus-continuous distinction that applies to data types more broadly, and the split determines which mathematical tools apply. A discrete random variable takes a countable set of distinct values — the number of defective items in a batch, the number of customers arriving in an hour — and its behavior is described by a probability mass function, which assigns an actual probability to each specific possible value. A continuous random variable can take any value within a range — a person's exact height, a reaction time measured to arbitrary precision — and its behavior is described instead by a probability density function, since the probability of any single exact continuous value is technically zero, and only the probability of falling within a range is meaningfully defined.

Uncertain, random process
a coin flip, a customer's purchase timing, tomorrow's weather
Random variable
maps every possible outcome to a number, with a probability attached
Discrete vs continuous
Discrete
probability mass function — exact values have real probabilities
Continuous
probability density function — only ranges have meaningful probability
A specific probability distribution describes its full behavior
normal, binomial, Poisson, and others

Every random variable has an associated probability distribution, which fully describes how probability is spread across its possible values — the normal distribution, binomial distribution, and Poisson distribution are all specific, named probability distributions that different kinds of random variables commonly follow, chosen based on the real-world process generating the data rather than arbitrarily. A random variable's distribution determines two of its most important summary properties: its expected value (the long-run average outcome if the underlying random process were repeated indefinitely, which is not the same as the single most likely outcome of any individual trial) and its variance (how spread out its possible outcomes are around that expected value) — both of which are computed directly from the distribution rather than from any single observed outcome.

Random variables are formally defined as functions from a sample space (the complete set of every possible outcome of a random process) to real numbers, a definition that matters practically because it's what allows two or more random variables to be combined, compared, and reasoned about using ordinary mathematical operations — adding two random variables together, for instance (total sales across two independent stores), produces a new random variable with its own, mathematically derivable distribution, expected value, and variance, built directly from the properties of the two original variables.

In applied data science, nearly every column in a dataset can be conceptually treated as an observed realization of some underlying random variable — a specific recorded customer age is one particular outcome drawn from the broader random variable "customer age," and statistical modeling is, at its core, the attempt to characterize that underlying random variable's distribution well enough from the limited, observed realizations available to make reliable predictions or inferences about values not yet observed.

Read a random variable as the formal bridge between an uncertain, real-world process and the mathematics of probability and statistics: assigning numbers to outcomes is what makes expected value, variance, and the full apparatus of statistical inference applicable to uncertainty in the first place, the discrete-versus-continuous split determines whether its behavior is described by a probability mass function or a probability density function, and nearly every statistical and machine learning model built on observed data is, implicitly, an attempt to characterize the underlying random variable that data is assumed to be a sample of realizations from.

Take random variable further

Ask the copilot about this term, or have our engineers assess it against your process.