Lesson 6 / 13 · 12 min read
Random Variables & Expected Value
Probability distributions, expected value, and the variance of a random variable.
What is a random variable?
A random variable X assigns a number to each outcome of a random process. Discrete random variables take countable values (a dice roll, a count of successes); continuous ones take any value in a range (a height, a waiting time).
Probability distribution
For a discrete random variable, the distribution lists each value with its probability. Every probability is between 0 and 1, and they sum to 1.
Example. X = the number on a fair die. P(X=k)=61 for k=1,2,…,6.
Expected value (the mean of a random variable)
E[X]=μ=∑ixiP(xi)
It's the long-run average if you repeated the process forever — each value weighted by its probability.
Example (fair die). E[X]=(1+2+3+4+5+6)⋅61=621=3.5.
Example (a game). Win $5 with probability 0.2, otherwise lose $2:
E[profit]=0.2(5)+0.8(−2)=1−1.6=−0.6
You lose about 60 cents per play on average.
Variance and standard deviation
Variance measures spread around the mean:
Var(X)=σ2=∑i(xi−μ)2P(xi)
and the standard deviation is σ=Var(X).
Example. X pays 0 with probability 0.5 and 10 with probability 0.5. Then μ=5, and
Var(X)=(0−5)2(0.5)+(10−5)2(0.5)=12.5+12.5=25
so σ=5.
Transformation rules
For constants a and b:
E[aX+b]=aE[X]+b Var(aX+b)=a2Var(X)
Adding a constant shifts the mean but leaves the spread alone; multiplying scales the mean by a and the variance by a2.
Sums of random variables
E[X+Y]=E[X]+E[Y](always) Var(X+Y)=Var(X)+Var(Y)(if independent)
Means always add. Variances add only when the variables are independent.
Key takeaways
- A random variable turns outcomes into numbers, with a probability distribution that sums to 1.
- E[X]=∑xiP(xi) is the long-run average.
- Var(X)=∑(xi−μ)2P(xi); σ is its square root.
- E[aX+b]=aE[X]+b and Var(aX+b)=a2Var(X).
- Means always add; variances add for independent variables.