A random variable turns the outcomes of a chance experiment into numbers, and the expected value tells you the long-run average of those numbers. These two ideas are the foundation of probability theory, from FSc and A Level statistics to university courses in finance, data science and engineering. This guide explains both clearly and shows every step in three worked examples.
What Is a Random Variable?
A random variable is a rule that assigns a number to each outcome of an experiment. We usually write it with a capital letter such as \( X \), and its particular values with lower case, such as \( x \).
- A discrete random variable takes separate, countable values: the score on a die, the number of heads in 10 tosses.
- A continuous random variable takes any value in an interval: a person's height, the time a bus arrives.
This article focuses on discrete random variables.
Probability Distributions
The probability distribution of a discrete random variable lists each possible value with its probability \( P(X = x) \). Two conditions must hold:
- \( 0 \leq P(X = x) \leq 1 \) for every \( x \).
- \( \sum P(X = x) = 1 \).
Expected Value
The expected value (or mean) of \( X \) is the probability-weighted average of its values:
$$ E(X) = \mu = \sum x \, P(X = x) $$
It does not have to be a value \( X \) can actually take. Think of it as the average result you would get if you repeated the experiment a very large number of times.
Variance and Standard Deviation
The variance measures spread around the mean. The most convenient formula is
$$ \text{Var}(X) = E(X^2) - [E(X)]^2, \qquad \text{where } E(X^2) = \sum x^2 \, P(X = x) $$
The standard deviation is \( \sigma = \sqrt{\text{Var}(X)} \), which is in the same units as \( X \).
Worked Example 1: A Fair Die
Let \( X \) be the score on a fair six-sided die. Each value from 1 to 6 has probability \( \frac{1}{6} \).
Step 1: Expected value.
$$ E(X) = \frac{1}{6}(1 + 2 + 3 + 4 + 5 + 6) = \frac{21}{6} = 3.5 $$
You can never roll 3.5, but over many rolls the average score approaches 3.5.
Step 2: Find \( E(X^2) \).
$$ E(X^2) = \frac{1}{6}(1 + 4 + 9 + 16 + 25 + 36) = \frac{91}{6} \approx 15.167 $$
Step 3: Variance.
$$ \text{Var}(X) = \frac{91}{6} - (3.5)^2 = \frac{91}{6} - \frac{49}{4} = \frac{182}{12} - \frac{147}{12} = \frac{35}{12} \approx 2.917 $$
Step 4: Standard deviation.
$$ \sigma = \sqrt{\frac{35}{12}} \approx 1.708 $$
Worked Example 2: Is the Game Fair?
A stall charges Rs 100 per ticket. A ticket wins Rs 5000 with probability 0.01, wins Rs 500 with probability 0.05, and otherwise wins nothing. Should you play?
Step 1: Define the random variable. Let \( W \) be the prize won.
| Prize \( w \) (Rs) | \( P(W = w) \) | \( w \, P(W = w) \) |
|---|---|---|
| 5000 | 0.01 | 50 |
| 500 | 0.05 | 25 |
| 0 | 0.94 | 0 |
Check: \( 0.01 + 0.05 + 0.94 = 1 \).
Step 2: Expected prize.
$$ E(W) = 50 + 25 + 0 = 75 $$
Step 3: Expected profit. Your profit is \( W - 100 \), so
$$ E(W - 100) = 75 - 100 = -25 $$
On average you lose Rs 25 per ticket. A game is fair only when the expected profit is zero, so this game favours the stall owner.
Rules for Linear Combinations
If \( a \) and \( b \) are constants, then
$$ E(aX + b) = aE(X) + b $$
$$ \text{Var}(aX + b) = a^2 \, \text{Var}(X) $$
Adding a constant shifts the mean but does not change the spread. Multiplying by \( a \) scales the variance by \( a^2 \).
Worked Example 3: Using the Rules
A random variable \( X \) has the distribution:
| \( x \) | \( P(X = x) \) |
|---|---|
| 0 | 0.1 |
| 1 | 0.3 |
| 2 | 0.4 |
| 3 | 0.2 |
Find \( E(X) \), \( \text{Var}(X) \), and the mean and variance of \( Y = 2X + 3 \).
Step 1: Expected value.
$$ E(X) = 0(0.1) + 1(0.3) + 2(0.4) + 3(0.2) = 0 + 0.3 + 0.8 + 0.6 = 1.7 $$
Step 2: \( E(X^2) \).
$$ E(X^2) = 0(0.1) + 1(0.3) + 4(0.4) + 9(0.2) = 0 + 0.3 + 1.6 + 1.8 = 3.7 $$
Step 3: Variance.
$$ \text{Var}(X) = 3.7 - (1.7)^2 = 3.7 - 2.89 = 0.81 $$
So \( \sigma = \sqrt{0.81} = 0.9 \).
Step 4: Apply the rules to \( Y = 2X + 3 \).
$$ E(Y) = 2(1.7) + 3 = 6.4 $$
$$ \text{Var}(Y) = 2^2 (0.81) = 4 \times 0.81 = 3.24 $$
Notice the "+3" has no effect on the variance.
Common Mistakes
- Writing \( \text{Var}(X) = E(X^2) - E(X) \). The mean must be squared: \( [E(X)]^2 \).
- Confusing \( E(X^2) \) with \( [E(X)]^2 \). In Example 3 these are 3.7 and 2.89, which are different.
- Writing \( \text{Var}(aX + b) = a\,\text{Var}(X) + b \). The correct result is \( a^2 \text{Var}(X) \).
- Not checking the probabilities sum to 1. This catches many errors early.
- Forgetting the cost in game problems. Expected prize and expected profit are different.
Key Takeaways
- A random variable assigns numbers to outcomes; its distribution lists values with probabilities summing to 1.
- \( E(X) = \sum x P(X = x) \) is the long-run average.
- \( \text{Var}(X) = E(X^2) - [E(X)]^2 \), and the standard deviation is its square root.
- \( E(aX + b) = aE(X) + b \) and \( \text{Var}(aX + b) = a^2 \text{Var}(X) \).
- A game is fair when the expected profit is zero.
Need help with probability distributions or a statistics assignment? Reach Amathify's experts and PhD scholars on WhatsApp or through the "Ask a Question" form for detailed, step-by-step solutions.
Stuck on a problem or assignment?
Our experts and PhD scholars solve maths, physics and chemistry — step by step.