Random variables give you a way to assign numbers to the outcomes of random processes, which turns uncertainty into something you can actually calculate with. They're the bridge between abstract probability and the kind of quantitative analysis you'll use throughout statistics, science, and decision-making.
This topic covers the definition and types of random variables, their key properties (expected value, variance), how to work with multiple random variables together, and the major theorems that make large-sample statistics possible.
Definition of random variables
A random variable is a function that maps each outcome of a random experiment to a real number. Instead of talking about "heads" or "tails," you assign numerical values (like 1 and 0), which lets you use all the tools of algebra and calculus on probabilistic outcomes.
Discrete vs continuous variables
The two main types of random variables differ in what values they can take:
- Discrete random variables take on countable, distinct values. Think of things you can list out: the number of customers in a store (0, 1, 2, ...), the number of heads in 10 coin flips, or the result of rolling a die.
- Continuous random variables can assume any value within a range. These describe measurements like temperature, height, or time, where values aren't restricted to whole numbers.
This distinction matters because each type uses a different mathematical tool to describe its probabilities: discrete variables use probability mass functions (PMFs), while continuous variables use probability density functions (PDFs).
Probability distributions
A probability distribution is a mathematical function that tells you how likely each outcome (or range of outcomes) is for a given random variable.
- Probability mass function (PMF) applies to discrete variables and gives the exact probability of each specific outcome.
- Probability density function (PDF) applies to continuous variables and gives the relative likelihood of values. For continuous variables, you find probabilities by integrating the PDF over an interval, not by evaluating it at a single point.
- Cumulative distribution function (CDF) works for both types and gives the probability that the variable is less than or equal to a given value: .
Common named distributions include the uniform, normal, exponential, and Poisson, each of which models a different kind of real-world scenario.
Expected value
The expected value (or mean) of a random variable represents its long-run average if you repeated the experiment many times. It's a measure of central tendency.
- For discrete variables:
- For continuous variables:
You multiply each possible outcome by its probability, then add everything up. For example, if a game pays $10 with probability 0.3 and $0 with probability 0.7, the expected value is dollars per play. This kind of calculation shows up constantly in risk assessment and decision-making.
Types of random variables
Different situations call for different probability models. Recognizing which random variable fits a scenario is a key skill, because each one comes with its own formulas for probabilities, expected values, and variances.
Bernoulli random variables
The Bernoulli random variable is the simplest discrete type: it has only two outcomes, typically coded as 1 ("success") and 0 ("failure").
- PMF:
- Expected value:
- Variance:
A single coin flip is the classic example. Any yes/no question with a fixed probability of "yes" can be modeled this way: Does a manufactured part pass inspection? Does a patient test positive?
Binomial random variables
If you repeat a Bernoulli trial independent times and count the total number of successes, you get a binomial random variable.
- PMF:
- Expected value:
- Variance:
For example, if a factory produces items with a 5% defect rate and you inspect a batch of 20, the number of defective items follows a binomial distribution with and . The expected number of defects is .
Poisson random variables
The Poisson distribution models the number of events occurring in a fixed interval of time or space, where events happen independently at a constant average rate.
- PMF:
- Both the expected value and variance equal (the rate parameter).
This is the go-to model for counting rare or random occurrences: the number of emails you receive per hour, radioactive decay events per second, or traffic accidents at an intersection per month. The Poisson distribution also serves as a good approximation to the binomial when is large and is small (with ).
Normal random variables
The normal (Gaussian) distribution is the most important continuous distribution. Its PDF produces the familiar symmetric, bell-shaped curve.
- PDF:
- Characterized by two parameters: the mean (center) and standard deviation (spread).
The standard normal distribution is the special case where and . You convert any normal variable to a standard normal using the Z-score: .
The normal distribution appears everywhere because of the Central Limit Theorem (covered below), which says that averages of many independent random variables tend toward a normal distribution regardless of the original distribution. Heights, IQ scores, and measurement errors all approximately follow normal distributions.
Properties of random variables
Variance and standard deviation
While expected value tells you where a distribution is centered, variance tells you how spread out it is. It measures the average squared distance from the mean.
- For discrete variables:
- For continuous variables:
- A useful shortcut:
Standard deviation is the square root of variance: . It's often more intuitive because it's in the same units as the original variable. If heights have a standard deviation of 3 inches, that directly tells you how much heights typically vary from the mean.
Moments of random variables
Moments are a family of summary statistics that describe different aspects of a distribution's shape:
- The 1st moment is the mean (expected value).
- The 2nd central moment is the variance.
- The 3rd central moment relates to skewness (how asymmetric the distribution is).
- The 4th central moment relates to kurtosis (how heavy the tails are).
The moment generating function (MGF) compactly encodes all moments:
You can extract the th moment by taking the th derivative and evaluating at : . MGFs are especially useful for proving theoretical results about distributions.
Probability density function
A few key properties of the PDF that are worth keeping straight:
- The PDF must be non-negative everywhere and must integrate to 1 over its entire domain.
- The PDF value at a single point is not a probability. For continuous variables, for any specific . Instead, you find probabilities over intervals by integrating: .
- The PDF is the derivative of the CDF: .

Functions of random variables
When you apply a function to a random variable, you create a new random variable. Understanding how transformations affect expected values and variances is essential for modeling.
Linear transformations
A linear transformation takes the form , where and are constants.
- Expected value:
- Variance:
Notice that adding a constant shifts the mean but doesn't change the variance. Multiplying by scales both the mean and the standard deviation (by ), while the variance scales by .
The most common application is standardization (computing Z-scores): , which is a linear transformation with and .
Non-linear transformations
When for some non-linear function , the distribution of can look very different from that of .
- Expected value:
- An important caution: in general, . For instance, . This is a common mistake.
Examples include logarithmic transformations (used in modeling multiplicative processes like stock returns) and squaring (used in computing variance itself).
Moment generating functions
The MGF is a powerful theoretical tool for several reasons:
- It uniquely determines a distribution. If two random variables have the same MGF, they have the same distribution.
- For sums of independent random variables, MGFs multiply: . This makes it much easier to find the distribution of a sum.
- It provides a systematic way to compute moments by differentiation.
Joint random variables
So far we've looked at single random variables in isolation. In practice, you often care about the relationship between two or more variables simultaneously.
Joint probability distributions
A joint distribution describes the probability behavior of two (or more) random variables together.
- For discrete variables, the joint PMF gives for every pair .
- For continuous variables, the joint PDF gives the relative likelihood of each pair of values.
- Both must be non-negative and sum (or integrate) to 1 over all possible pairs.
For example, you might model the joint distribution of height and weight in a population, where knowing someone's height gives you information about their likely weight.
Marginal distributions
A marginal distribution extracts the distribution of one variable from a joint distribution by "summing out" the other variable.
- For discrete variables:
- For continuous variables:
The marginal distribution tells you about one variable alone, ignoring the other. You can always recover marginals from a joint distribution, but you generally cannot reconstruct the joint distribution from marginals alone (because the marginals don't capture the relationship between the variables).
Conditional distributions
A conditional distribution describes one variable given that the other takes a specific value.
- For discrete variables:
- For continuous variables:
This is the probability version of asking "given that Y equals some value, what does X look like?" Conditional distributions are central to Bayesian inference, where you update your beliefs about a parameter after observing data. They also appear in medical diagnosis (probability of disease given a positive test) and weather forecasting (probability of rain given current atmospheric conditions).
Independence of random variables
Definition of independence
Two random variables and are independent if knowing the value of one tells you nothing about the other. Formally, their joint distribution factors into the product of their marginals:
- For discrete variables: for all
- For continuous variables: for all
Independence is a strong condition. It means the conditional distribution of given is the same as the unconditional distribution of . This concept extends naturally to more than two variables.
Properties of independent variables
When and are independent, several calculations simplify dramatically:
- MGFs multiply:
The variance addition property is especially important. For dependent variables, you'd need to include a covariance term: . Independence makes that covariance term zero.
These properties are also what make the Central Limit Theorem work, since it requires independent (or at least uncorrelated) variables.
Covariance and correlation
Covariance measures how two random variables move together:
- Positive covariance: when is above its mean, tends to be above its mean too.
- Negative covariance: they tend to move in opposite directions.
- Zero covariance: no linear relationship.
The correlation coefficient standardizes covariance to a scale from to :
A correlation of means a perfect linear relationship. A correlation of 0 means no linear relationship. One important subtlety: independent variables always have zero correlation, but zero correlation does not guarantee independence. Two variables can be uncorrelated yet still dependent through a non-linear relationship.

Limit theorems
Limit theorems describe what happens to random variables as sample sizes grow large. They're the theoretical backbone of statistical inference.
Law of large numbers
The Law of Large Numbers (LLN) says that as you take more and more observations, the sample mean converges to the true expected value.
- Weak law: the sample mean converges to in probability (the chance of being far from shrinks to zero).
- Strong law: the sample mean converges to almost surely (with probability 1).
This formalizes the intuition that if you flip a fair coin thousands of times, the proportion of heads will settle close to 0.5. It's the foundation of insurance pricing, casino profitability, and any setting where long-run averages matter.
Central limit theorem
The Central Limit Theorem (CLT) is arguably the most important result in probability and statistics. It states that if you take independent, identically distributed random variables with mean and standard deviation , their standardized sum approaches a standard normal distribution as grows:
The remarkable thing is that this works regardless of the original distribution. Whether the individual variables are uniform, exponential, or something else entirely, the sum still tends toward normal. This is why the normal distribution shows up so often in practice, and it's the reason confidence intervals and many hypothesis tests are built on normal approximations.
Chebyshev's inequality
Chebyshev's inequality gives a universal bound on how far a random variable can stray from its mean:
This holds for any distribution with a finite mean and variance. For example, at least 75% of any distribution's values lie within 2 standard deviations of the mean (since ), and at least 89% lie within 3 standard deviations.
The bound is often loose (the normal distribution does much better than Chebyshev predicts), but its power is in its generality. It's also used to prove the weak law of large numbers.
Applications in probability theory
Stochastic processes
A stochastic process is a collection of random variables indexed by time (or space). Instead of a single random outcome, you're tracking how randomness evolves.
- Markov chains: discrete-time processes where the next state depends only on the current state.
- Poisson processes: model random events occurring continuously over time at a constant rate.
- Brownian motion: models continuous random movement, foundational in physics and finance.
Applications span stock price modeling, particle diffusion, population dynamics, and queueing systems.
Markov chains
A Markov chain is a stochastic process with the memoryless property: the probability of the next state depends only on the current state, not on how you got there.
The chain is fully described by its transition probability matrix, where entry gives the probability of moving from state to state . Over many steps, many Markov chains converge to a stationary distribution that doesn't change with further transitions.
Applications include Google's PageRank algorithm (modeling a random web surfer), weather prediction models, inventory management, and DNA sequence analysis.
Monte Carlo simulations
Monte Carlo methods use repeated random sampling to estimate quantities that are difficult or impossible to compute analytically.
The basic approach:
- Define the problem and identify the random inputs.
- Generate a large number of random samples from the appropriate distributions.
- Compute the quantity of interest for each sample.
- Average the results to get an estimate.
As the number of samples increases, the estimate converges to the true value (by the Law of Large Numbers). Monte Carlo methods are used in option pricing in finance, particle physics simulations, engineering reliability analysis, and estimating complex integrals.
Random variables in statistics
Random variables provide the theoretical foundation for statistical methods. Every dataset can be thought of as a collection of realized values from random variables, and statistical inference is about working backward from those values to learn about the underlying distributions.
Parameter estimation
Parameter estimation uses observed data to estimate unknown population parameters (like the true mean or variance).
- Maximum likelihood estimation (MLE): finds the parameter values that make the observed data most probable.
- Method of moments: matches sample moments (mean, variance, etc.) to their theoretical counterparts and solves for the parameters.
- Point estimates give a single best guess for the parameter.
- Interval estimates (confidence intervals) provide a range that likely contains the true parameter, quantifying the uncertainty in your estimate.
Hypothesis testing
Hypothesis testing is a structured way to use data to decide between competing claims.
- State the null hypothesis (, the default assumption) and the alternative hypothesis ().
- Choose a significance level (, typically 0.05).
- Compute a test statistic from the data.
- Find the p-value: the probability of observing a result at least as extreme as yours, assuming is true.
- If the p-value is less than , reject .
The test statistic is itself a random variable, and its distribution under (often derived using the CLT) is what makes the whole framework work. Applications range from clinical drug trials to A/B testing in tech companies.
Confidence intervals
A confidence interval gives a range of plausible values for a population parameter based on sample data.
- A 95% confidence interval means: if you repeated the sampling process many times, about 95% of the resulting intervals would contain the true parameter.
- Wider intervals reflect greater uncertainty (smaller samples or higher variability).
- The formula for a confidence interval for a mean often relies on the CLT:
Confidence intervals are used in polling (margin of error), medical studies (treatment effect ranges), and engineering (tolerance specifications).