What is a random variable?
A chance experiment is something whose result you cannot know in advance, like tossing coins or rolling a die.
A random variable is a rule that turns each outcome into a number. We write it with a capital letter, like X.
Example: toss 3 coins and let X = number of heads. The outcome HTH gives X = 2. The outcome TTT gives X = 0.
It is called "random" because its value depends on chance, and "variable" because it can take different values.
Discrete and continuous random variables
A discrete random variable takes separate values you can list: number of heads, number of goals, number of defective bulbs in a box.
A continuous random variable can take any value in a range: height of a student, time to finish a race, mass of a mango.
For a continuous variable we do not give the chance of one exact value (that is 0). Instead a curve called the probability density function f(x) is drawn, and the area under the curve between two values is the probability. The total area under the curve is 1.
Probability distribution
A probability distribution is a table (or graph) of every value x with its probability P(X = x).
For 3 coins: x = 0, 1, 2, 3 with P = 1/8, 3/8, 3/8, 1/8.
Two rules must always hold:
- Each probability is between 0 and 1.
- All probabilities add up to exactly 1.
You can use these rules to find a missing value. If P(X = x) = k, 2k, 3k, 4k, then 10k = 1, so k = 0.1.
The cumulative probability P(X ≤ x) adds up all probabilities up to x.
Expected value (mean)
The expected value or mean is the average result you would get if you repeated the experiment a very large number of times.
E(X) = Σ x · P(X = x). Multiply each value by its probability and add.
For 3 coins: E(X) = 0·1/8 + 1·3/8 + 2·3/8 + 3·1/8 = 12/8 = 1.5.
E(X) need not be a value X can actually take. You never see 1.5 heads, but over many tosses the average is 1.5.
Useful rules: E(aX + b) = a·E(X) + b, and for two variables E(X + Y) = E(X) + E(Y).
Variance and standard deviation
Variance measures spread: how far values usually are from the mean.
Var(X) = E(X²) − [E(X)]², where E(X²) = Σ x² · P(x).
The standard deviation σ = √Var(X) is in the same units as X.
For 3 coins: E(X²) = 0 + 3/8 + 12/8 + 9/8 = 3, so Var = 3 − 2.25 = 0.75 and σ ≈ 0.87.
Rules: Var(aX + b) = a²·Var(X) (adding b does not change the spread). If X and Y are independent, Var(X + Y) = Var(X) + Var(Y).
For n independent tries each with success chance p (a binomial variable), E(X) = np and Var(X) = np(1 − p).
Using expected value to make decisions
A game is fair if your expected gain is 0.
Example: you pay ₹20 to roll a die. You win ₹60 on a six, nothing otherwise. Expected gain = 60 × 1/6 − 20 = 10 − 20 = −₹10 per game. On average you lose ₹10, so the game is not fair.
Companies compare the expected cost of choices, like whether to buy a warranty or which crop to plant, and pick the best expected value. But expected value is a long-run average; one single try can still go either way.
Try it: the coin table
Toss 3 coins 40 times. Each time write down how many heads you got. Make a tally for 0, 1, 2 and 3. Divide each tally by 40. Your fractions should be close to 0.125, 0.375, 0.375 and 0.125. Now add up all 40 results and divide by 40. The answer should be near 1.5, the expected value. Check it against step 4 of the 3D.
Key formulas and definitions
- Σ P(X = x) = 1, 0 ≤ P(x) ≤ 1
- E(X) = Σ x·P(x)
- Var(X) = E(X²) − [E(X)]², σ = √Var(X)
- E(aX + b) = aE(X) + b, Var(aX + b) = a²Var(X)
- Binomial: E(X) = np, Var(X) = np(1 − p)
Worked examples
1. Two coins are tossed. X = number of tails. Write the probability distribution.
Outcomes: HH, HT, TH, TT. X = 0 (HH), 1 (HT, TH), 2 (TT). So P(0) = 1/4, P(1) = 2/4 = 1/2, P(2) = 1/4. Check: 1/4 + 1/2 + 1/4 = 1.
2. P(X = x) is 0.1, k, 0.3, 2k for x = 0, 1, 2, 3. Find k.
All add to 1: 0.1 + k + 0.3 + 2k = 1 → 3k = 0.6 → k = 0.2.
3. A fair die is rolled. Find E(X), where X is the number shown.
Each face has probability 1/6. E(X) = (1 + 2 + 3 + 4 + 5 + 6)/6 = 21/6 = 3.5.
4. Find the variance of the die score.
E(X²) = (1 + 4 + 9 + 16 + 25 + 36)/6 = 91/6 ≈ 15.17. Var = 91/6 − 3.5² = 15.17 − 12.25 ≈ 2.92. σ ≈ 1.71.
5. X has P(0) = 0.2, P(1) = 0.5, P(2) = 0.3. Find E(X), Var(X) and E(3X + 2).
E(X) = 0 + 0.5 + 0.6 = 1.1. E(X²) = 0 + 0.5 + 1.2 = 1.7. Var = 1.7 − 1.21 = 0.49. E(3X + 2) = 3 × 1.1 + 2 = 5.3.
6. A raffle sells 500 tickets at ₹50. One prize is ₹10 000 and two prizes are ₹2 500. Find the expected gain of one ticket.
Expected winnings = 10 000 × 1/500 + 2 500 × 2/500 = 20 + 10 = ₹30. Expected gain = 30 − 50 = −₹20. On average a buyer loses ₹20.
7. A basketball player scores a free throw with probability 0.8. She takes 10 throws. Find the mean and SD of the number scored.
This is binomial with n = 10, p = 0.8. E(X) = 10 × 0.8 = 8. Var = 10 × 0.8 × 0.2 = 1.6. σ = √1.6 ≈ 1.26.
Common mistakes
- Forgetting to check that the probabilities add up to 1 before using the table.
- Writing Var(X) = E(X²) − E(X) instead of E(X²) − [E(X)]². The mean must be squared.
- Thinking E(X) must be a possible value of X. The mean number of heads can be 1.5.
- Using Var(aX + b) = a·Var(X) + b. The b drops out and a gets squared: a²·Var(X).