Introduction to Random Variables
From the Statistics curriculum
Introduction to Random Variables
TL;DR
A random variable is a way to turn the outcomes of a random experiment into numbers, making them easier to work with mathematically. You can have discrete random variables (countable outcomes) or continuous random variables (outcomes within a range). Understanding these helps you describe and predict probabilities for real-world events.
1. The Mental Model
Think of a random variable as a machine that takes a random event (like flipping a coin or rolling a die) and spits out a number related to that event. It's how we quantify uncertainty.
2. The Core Material
In statistics, we often deal with experiments whose outcomes aren't certain. For example, if you flip a coin, you don't know if it'll be heads or tails until it lands. A random variable is simply a function that assigns a numerical value to each possible outcome of a random experiment. This lets us use mathematical tools to analyze these outcomes.
We usually denote random variables with capital letters like $X$, $Y$, or $Z$. The actual value they take on for a specific experiment is written with lowercase letters, like $x$, $y$, or $z$.
Types of Random Variables

Photo by Arturo Añez. on Pexels
There are two main types:
-
Discrete Random Variables: These are random variables whose possible values are countable. This means you can list all the possible outcomes, even if the list is infinite.
- Examples:
- The number of heads when flipping a coin three times (0, 1, 2, 3).
- The number of cars passing a certain point on a highway in an hour (0, 1, 2, 3, ...).
- The number of defective items in a batch of 100.
- Examples:
-
Continuous Random Variables: These are random variables whose possible values can take any value within a given interval. You can't list all the outcomes because there are infinitely many possibilities between any two points.
- Examples:
- The height of a randomly selected person (e.g., between 150 cm and 190 cm).
- The time it takes for a bus to arrive (e.g., between 5 minutes and 15 minutes).
- The temperature in a room.
- Examples:
Let's look at how we map experiment outcomes to numerical values.
graph TD
A["Random Experiment"] --> B["Outcome (e.g., 'Heads', 'Tails')"];
B --> C{"Random Variable (e.g., X)"};
C --> D["Numerical Value (e.g., X=1 for Heads, X=0 for Tails)"];
D --> E["Mathematical Analysis / Probability"];
Probability Distribution of a Random Variable

Photo by Nascimento Jr. on Pexels
Once you have a random variable, the next step is to understand its probability distribution. This tells you what the possible values of the random variable are and how likely each value is to occur.
- For discrete random variables, we use a Probability Mass Function (PMF). It lists each possible value $x$ and its probability $P(X=x)$.
- For continuous random variables, we use a Probability Density Function (PDF). Instead of assigning probabilities to individual points (which would be zero for any single point), it describes the likelihood of the variable falling within a certain range.
3. Worked Example
Let's consider a simple experiment: rolling a standard six-sided die once.
- Define the Random Experiment: Rolling a single six-sided die.
- List all possible outcomes (Sample Space): {1, 2, 3, 4, 5, 6}
- Define a Random Variable: Let $X$ be the number shown on the top face of the die.
- Identify the type of Random Variable: Since the outcomes (1, 2, 3, 4, 5, 6) are countable, $X$ is a discrete random variable.
- Determine its Probability Distribution (PMF): Assuming a fair die, each outcome is equally likely.
| Value of $X$ ($x$) | $P(X=x)$ |
|---|---|
| 1 | 1/6 |
| 2 | 1/6 |
| 3 | 1/6 |
| 4 | 1/6 |
| 5 | 1/6 |
| 6 | 1/6 |
This table is the probability distribution (specifically, the PMF) for our random variable $X$. It tells us that the random variable $X$ can take on values 1 through 6, and each of those values has a 1/6 chance of occurring.
4. Key Takeaways
- A random variable converts non-numerical or uncertain outcomes of an experiment into numerical values.
- It allows you to apply mathematical methods to analyze random phenomena.
- Discrete random variables have countable outcomes, like the number of coin flips or defective items.
- Continuous random variables can take any value within a range, such as height, weight, or time.
- The probability distribution (PMF for discrete, PDF for continuous) describes how likely each value or range of values is.
- Random variables are foundational for understanding probability and statistical inference.
Common Mistakes to Avoid:

Photo by KATRIN BOLOVTSOVA on Pexels
- Don't confuse the random variable itself (the concept) with the specific value it takes in one experiment.
- Don't mix up discrete and continuous variables; they have different mathematical treatments.
- Remember that a random variable assigns a single numerical value to each outcome in the sample space.
- Don't assume all probabilities are equal for every value of a random variable; that's only true for specific distributions.
5. Now Try It
Think of an experiment where you pick two cards from a standard deck of 52 cards without replacement. Define a discrete random variable $X$ that represents "the number of aces drawn." List all possible values $X$ can take and describe in plain language what each value means in terms of the experiment's outcome. What does $P(X=2)$ mean in this context? (You don't need to calculate the probability, just explain what it represents.)
Frequently asked about Introduction to Random Variables
More from Statistics
Get the full Statistics curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Create Free Account