Random variables and their distributions · Mathematics… | StemPy Lab
Course 16.3·Lesson 1 of 3
Random variables and their distributions
A random variable turns each outcome of an experiment into a number. Its probability distribution lists the chance of each value. The mean E(X) is the long-run average and the variance Var(X)
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
write the probability distribution of a random variable and check that it adds up to 1;
find the mean and the variance of a random variable;
find the mean and the variance of aX+b, and decide whether a game is fair.
Counting heads
Toss a fair coin three times. The outcomes are HHH, HHT and so on, eight in all. Let X be the number of heads. Then X is a random variable: a rule that gives a number to every outcome. Here X can be 0, 1, 2 or 3.
Count the outcomes for each value. Only TTT gives 0 heads. Three outcomes give 1 head, three give 2 heads, and only HHH gives 3. The probability distribution of X is the table
x
0
1
2
3
P(X=x)
81
83
83
81
The probabilities are never negative, and they add up to 1, because every outcome gives exactly one value of X.
Mean and variance
The mean of X, also written E(X) or μ, is the average value in the long run. Multiply each value by its probability and add:
E(X)=∑xP(X=x).
For the heads, E(X)=0×81+1×83+2×83+3×81=812=1.5.
The variance measures how far the values spread around the mean. It is the average of (x−μ)2. A shorter form is easier to compute:
Var(X)=E(X2)−[E(X)]2,E(X2)=∑x2P(X=x).
The standard deviation is σ=Var(X), and it has the same unit as X. For the heads, E(X2)=80+3+12+9=3, so Var(X)=3−1.52=0.75.
Indian books write the mean as μ and the variance as σ2. A-Level and IB write E(X) and Var(X). AP writes μX and σX2. They are all the same numbers.
A bar chart of the larger number X when two fair dice are thrown. The bars for x = 1 to 6 have heights 1/36, 3/36, 5/36, 7/36, 9/36 and 11/36, labelled 0.028, 0.083, 0.139, 0.194, 0.25 and 0.306, rising to the right. A red dashed vertical line at 4.472 marks the mean.
A larger example
Two fair dice are thrown. Let X be the larger of the two numbers. The value x occurs in 2x−1 of the 36 outcomes, so P(X=x)=362x−1 for x=1,…,6. Then E(X)=36161≈4.472, and E(X2)=36791. So Var(X)=36791−(36161)2=12962555≈1.971. The mean is above 3.5, because the larger of two numbers tends to be large.
The effect of aX+b
If every value of X is multiplied by a and then b is added, the mean follows the same rule, but the spread does not feel b:
E(aX+b)=aE(X)+b,Var(aX+b)=a2Var(X).
Shifting by b moves every value together, so it does not change the spread. Stretching by a stretches the spread by a, and the variance, which uses squares, by a2. The standard deviation becomes ∣a∣σ.
A fair game
A game costs 3 coins to play. You throw a fair die and win 18 coins if it shows a six, and nothing otherwise. The winnings W are 18 with probability 61 and 0 otherwise, so E(W)=18×61=3. The expected net gain is 3−3=0. A game with expected net gain 0 is fair. If the cost were 5 coins, the expected net gain would be −2 coins: on average the player loses 2 coins a game.
Practise with new numbers
Try it in Python
The program finds the distribution of the larger of two dice by counting, and then the mean and the variance with exact fractions.
Common mistakes
Probabilities that do not add up to 1. Always check the total of a table.
Forgetting to square.E(X2) is not [E(X)]2. The difference is the variance.
Adding b to the variance.Var(aX+b)=a2Var(X), and b does not appear.
Mixing up the mean of X with a likely value. The mean need not be a value that X can take. The mean of a die is 3.5.
Remember these
A distribution is a table of values and probabilities that add up to 1.
E(X)=∑xp, and Var(X)=E(X2)−[E(X)]2.
E(aX+b)=aE(X)+b and Var(aX+b)=a2Var(X).
A game is fair when the expected net gain is 0.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
A random variable X takes the values 0,1,2,3 with P(X=x)=k(x+1). Find k.
A fair coin is tossed twice, and X is the number of heads. Find E(X) and Var(X).
A random variable has mean 4 and variance 9. Find the mean, the variance and the standard deviation of 3X−2.
A game costs 5 coins. You throw a fair die and win 24 coins for a six, and nothing otherwise. Is the game fair? What is the expected net gain?
Can a variance be negative? When is it zero?
References
OpenStax, Introductory Statistics, Chapter 4, sections on probability distribution functions and on the mean and standard deviation of a discrete random variable.
NCERT, Mathematics Part II for Class XII, Chapter 13, sections on random variables and their probability distributions, and on the mean and variance of a random variable.
Enroll free in Random Variables and the Binomial Distribution
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.