Random variables and expectation
A random variable X X X is a function from the sample space to the real numbers , it assigns a numerical value to each outcome. Most of the time, instead of thinking about complicated outcome events, we work with the distribution of X X X : the list of possible values it can take, and their probabilities.
Definition
Formally, X : Ω → R X : \Omega \to \mathbb{R} X : Ω → R is a real-valued function on the sample space Ω \Omega Ω .
For discrete random variables (the Class XII focus), X X X takes finitely or countably many values x 1 , x 2 , … x_1, x_2, \ldots x 1 , x 2 , … . The probability mass function (PMF) gives the probability of each value:
p i = P ( X = x i ) , p_i = P(X = x_i), p i = P ( X = x i ) ,
with ∑ i p i = 1 \sum_i p_i = 1 ∑ i p i = 1 .
Examples of random variables
X = X = X = number on a die: values { 1 , 2 , 3 , 4 , 5 , 6 } \{1, 2, 3, 4, 5, 6\} { 1 , 2 , 3 , 4 , 5 , 6 } , each with probability 1 / 6 1/6 1/6 .
X = X = X = number of heads in 3 coin flips: values { 0 , 1 , 2 , 3 } \{0, 1, 2, 3\} { 0 , 1 , 2 , 3 } , probabilities 1 / 8 , 3 / 8 , 3 / 8 , 1 / 8 1/8, 3/8, 3/8, 1/8 1/8 , 3/8 , 3/8 , 1/8 .
X = X = X = number of red balls drawn in 2 draws (without replacement) from a bag with 4 red, 6 blue.
Probability distribution table
A common way to present a discrete PMF:
X X X x 1 x_1 x 1 x 2 x_2 x 2 x 3 x_3 x 3 ⋯ \cdots ⋯ P ( X ) P(X) P ( X ) p 1 p_1 p 1 p 2 p_2 p 2 p 3 p_3 p 3 ⋯ \cdots ⋯
Always check: probabilities are non-negative and sum to 1.
Expectation
The expected value (or mean) of a discrete random variable X X X is
E [ X ] = μ = ∑ i x i p i . E[X] = \mu = \sum_i x_i\, p_i. E [ X ] = μ = ∑ i x i p i .
It is the weighted average of the values, weighted by their probabilities. Interpretation: if you repeat the experiment many times, E [ X ] E[X] E [ X ] is the long-run average of X X X .
Properties of expectation:
Linearity: E [ a X + b ] = a E [ X ] + b E[aX + b] = aE[X] + b E [ a X + b ] = a E [ X ] + b .
For two random variables: E [ X + Y ] = E [ X ] + E [ Y ] E[X + Y] = E[X] + E[Y] E [ X + Y ] = E [ X ] + E [ Y ] (always, even if not independent).
For independent X , Y X, Y X , Y : E [ X Y ] = E [ X ] E [ Y ] E[XY] = E[X]\,E[Y] E [ X Y ] = E [ X ] E [ Y ] .
Variance and standard deviation
The variance measures spread:
V a r ( X ) = σ 2 = E [ ( X − μ ) 2 ] = ∑ i ( x i − μ ) 2 p i . \mathrm{Var}(X) = \sigma^2 = E[(X - \mu)^2] = \sum_i (x_i - \mu)^2 p_i. Var ( X ) = σ 2 = E [( X − μ ) 2 ] = ∑ i ( x i − μ ) 2 p i .
A useful computational form:
V a r ( X ) = E [ X 2 ] − ( E [ X ] ) 2 . \mathrm{Var}(X) = E[X^2] - (E[X])^2. Var ( X ) = E [ X 2 ] − ( E [ X ] ) 2 .
The standard deviation is σ = V a r ( X ) \sigma = \sqrt{\mathrm{Var}(X)} σ = Var ( X ) , in the same units as X X X .
Properties:
V a r ( a X + b ) = a 2 V a r ( X ) \mathrm{Var}(aX + b) = a^2\,\mathrm{Var}(X) Var ( a X + b ) = a 2 Var ( X ) . (Shifts don't affect spread; scaling squares.)
For independent X , Y X, Y X , Y : V a r ( X + Y ) = V a r ( X ) + V a r ( Y ) \mathrm{Var}(X + Y) = \mathrm{Var}(X) + \mathrm{Var}(Y) Var ( X + Y ) = Var ( X ) + Var ( Y ) .
Worked examples
Example 1. X X X = score on a fair die. Find E [ X ] E[X] E [ X ] and V a r ( X ) \mathrm{Var}(X) Var ( X ) .
E [ X ] = ( 1 + 2 + 3 + 4 + 5 + 6 ) / 6 = 21 / 6 = 7 / 2 = 3.5 E[X] = (1 + 2 + 3 + 4 + 5 + 6)/6 = 21/6 = 7/2 = 3.5 E [ X ] = ( 1 + 2 + 3 + 4 + 5 + 6 ) /6 = 21/6 = 7/2 = 3.5 .
E [ X 2 ] = ( 1 + 4 + 9 + 16 + 25 + 36 ) / 6 = 91 / 6 E[X^2] = (1 + 4 + 9 + 16 + 25 + 36)/6 = 91/6 E [ X 2 ] = ( 1 + 4 + 9 + 16 + 25 + 36 ) /6 = 91/6 .
V a r ( X ) = 91 / 6 − ( 7 / 2 ) 2 = 91 / 6 − 49 / 4 = 182 / 12 − 147 / 12 = 35 / 12 ≈ 2.917 \mathrm{Var}(X) = 91/6 - (7/2)^2 = 91/6 - 49/4 = 182/12 - 147/12 = 35/12 \approx 2.917 Var ( X ) = 91/6 − ( 7/2 ) 2 = 91/6 − 49/4 = 182/12 − 147/12 = 35/12 ≈ 2.917 .
Example 2. Two coins are flipped. X X X = number of heads. Find the distribution, E [ X ] E[X] E [ X ] , V a r ( X ) \mathrm{Var}(X) Var ( X ) .
E [ X ] = 0 ( 1 / 4 ) + 1 ( 1 / 2 ) + 2 ( 1 / 4 ) = 1 E[X] = 0(1/4) + 1(1/2) + 2(1/4) = 1 E [ X ] = 0 ( 1/4 ) + 1 ( 1/2 ) + 2 ( 1/4 ) = 1 .
E [ X 2 ] = 0 + 1 ( 1 / 2 ) + 4 ( 1 / 4 ) = 3 / 2 E[X^2] = 0 + 1(1/2) + 4(1/4) = 3/2 E [ X 2 ] = 0 + 1 ( 1/2 ) + 4 ( 1/4 ) = 3/2 .
V a r ( X ) = 3 / 2 − 1 = 1 / 2 \mathrm{Var}(X) = 3/2 - 1 = 1/2 Var ( X ) = 3/2 − 1 = 1/2 .
Example 3. A coin is flipped repeatedly until heads appears (or until 4 flips). Let X X X = number of flips. Find the distribution.
X = 1 X = 1 X = 1 : heads on first flip, P = 1 / 2 P = 1/2 P = 1/2 .
X = 2 X = 2 X = 2 : TH, P = 1 / 4 P = 1/4 P = 1/4 .
X = 3 X = 3 X = 3 : TTH, P = 1 / 8 P = 1/8 P = 1/8 .
X = 4 X = 4 X = 4 : TTTH or TTTT, P = 1 / 16 + 1 / 16 = 1 / 8 P = 1/16 + 1/16 = 1/8 P = 1/16 + 1/16 = 1/8 (either heads-on-4th or four-tails-and-stop).
Wait, the latter case "TTTT and stop" is also "X = 4 X = 4 X = 4 " by our definition. So P ( X = 4 ) = 1 / 16 + 1 / 16 = 1 / 8 P(X = 4) = 1/16 + 1/16 = 1/8 P ( X = 4 ) = 1/16 + 1/16 = 1/8 . Check sum: 1 / 2 + 1 / 4 + 1 / 8 + 1 / 8 = 1 1/2 + 1/4 + 1/8 + 1/8 = 1 1/2 + 1/4 + 1/8 + 1/8 = 1 ✓.
E [ X ] = 1 ( 1 / 2 ) + 2 ( 1 / 4 ) + 3 ( 1 / 8 ) + 4 ( 1 / 8 ) = 1 / 2 + 1 / 2 + 3 / 8 + 1 / 2 = 15 / 8 E[X] = 1(1/2) + 2(1/4) + 3(1/8) + 4(1/8) = 1/2 + 1/2 + 3/8 + 1/2 = 15/8 E [ X ] = 1 ( 1/2 ) + 2 ( 1/4 ) + 3 ( 1/8 ) + 4 ( 1/8 ) = 1/2 + 1/2 + 3/8 + 1/2 = 15/8 .
Example 4. A box has 4 white and 2 black balls. Two balls are drawn without replacement. Let X X X = number of white balls. Find distribution and mean.
X = 0 X = 0 X = 0 : both black. P = ( 2 2 ) / ( 6 2 ) = 1 / 15 P = \binom{2}{2}/\binom{6}{2} = 1/15 P = ( 2 2 ) / ( 2 6 ) = 1/15 .
X = 1 X = 1 X = 1 : one of each. P = ( 4 1 ) ( 2 1 ) / ( 6 2 ) = 8 / 15 P = \binom{4}{1}\binom{2}{1}/\binom{6}{2} = 8/15 P = ( 1 4 ) ( 1 2 ) / ( 2 6 ) = 8/15 .
X = 2 X = 2 X = 2 : both white. P = ( 4 2 ) / ( 6 2 ) = 6 / 15 P = \binom{4}{2}/\binom{6}{2} = 6/15 P = ( 2 4 ) / ( 2 6 ) = 6/15 .
Check: 1 / 15 + 8 / 15 + 6 / 15 = 15 / 15 1/15 + 8/15 + 6/15 = 15/15 1/15 + 8/15 + 6/15 = 15/15 ✓.
E [ X ] = 0 ( 1 / 15 ) + 1 ( 8 / 15 ) + 2 ( 6 / 15 ) = 0 + 8 / 15 + 12 / 15 = 20 / 15 = 4 / 3 E[X] = 0(1/15) + 1(8/15) + 2(6/15) = 0 + 8/15 + 12/15 = 20/15 = 4/3 E [ X ] = 0 ( 1/15 ) + 1 ( 8/15 ) + 2 ( 6/15 ) = 0 + 8/15 + 12/15 = 20/15 = 4/3 .
Example 5. A lottery ticket costs ₹10 10 10 . Probability of winning ₹1000 1000 1000 is 0.005 0.005 0.005 ; otherwise nothing. Find the expected net gain.
X X X = net gain. X = − 10 X = -10 X = − 10 with probability 0.995 0.995 0.995 (lose ₹10), X = 990 X = 990 X = 990 with probability 0.005 0.005 0.005 (win ₹1000 minus ₹10 spent).
E [ X ] = − 10 ( 0.995 ) + 990 ( 0.005 ) = − 9.95 + 4.95 = − 5 E[X] = -10(0.995) + 990(0.005) = -9.95 + 4.95 = -5 E [ X ] = − 10 ( 0.995 ) + 990 ( 0.005 ) = − 9.95 + 4.95 = − 5 . Expected loss of ₹5.
Example 6. A random variable X X X takes values 1 , 2 , 3 1, 2, 3 1 , 2 , 3 with probabilities 1 / 6 , 1 / 3 , 1 / 2 1/6, 1/3, 1/2 1/6 , 1/3 , 1/2 . Find E [ X ] , E [ X 2 ] , V a r ( X ) E[X], E[X^2], \mathrm{Var}(X) E [ X ] , E [ X 2 ] , Var ( X ) .
E [ X ] = 1 ( 1 / 6 ) + 2 ( 1 / 3 ) + 3 ( 1 / 2 ) = 1 / 6 + 4 / 6 + 9 / 6 = 14 / 6 = 7 / 3 E[X] = 1(1/6) + 2(1/3) + 3(1/2) = 1/6 + 4/6 + 9/6 = 14/6 = 7/3 E [ X ] = 1 ( 1/6 ) + 2 ( 1/3 ) + 3 ( 1/2 ) = 1/6 + 4/6 + 9/6 = 14/6 = 7/3 .
E [ X 2 ] = 1 ( 1 / 6 ) + 4 ( 1 / 3 ) + 9 ( 1 / 2 ) = 1 / 6 + 8 / 6 + 27 / 6 = 36 / 6 = 6 E[X^2] = 1(1/6) + 4(1/3) + 9(1/2) = 1/6 + 8/6 + 27/6 = 36/6 = 6 E [ X 2 ] = 1 ( 1/6 ) + 4 ( 1/3 ) + 9 ( 1/2 ) = 1/6 + 8/6 + 27/6 = 36/6 = 6 .
V a r ( X ) = 6 − 49 / 9 = 54 / 9 − 49 / 9 = 5 / 9 \mathrm{Var}(X) = 6 - 49/9 = 54/9 - 49/9 = 5/9 Var ( X ) = 6 − 49/9 = 54/9 − 49/9 = 5/9 .
Try it yourself
X X X = number of heads in 4 fair coin flips. Find the distribution, E [ X ] , V a r ( X ) E[X], \mathrm{Var}(X) E [ X ] , Var ( X ) .
A die is rolled; X X X = score if even, 0 0 0 if odd. Find E [ X ] E[X] E [ X ] .
X X X = sum of two dice. Find E [ X ] E[X] E [ X ] and V a r ( X ) \mathrm{Var}(X) Var ( X ) .
A box has 5 R, 3 B balls. Two drawn without replacement; X X X = red balls. Find distribution and E [ X ] E[X] E [ X ] .
Three coins. X X X = number of tails. Find E [ X ] , V a r ( X ) E[X], \mathrm{Var}(X) E [ X ] , Var ( X ) .
X X X takes values − 2 , − 1 , 0 , 1 , 2 -2, -1, 0, 1, 2 − 2 , − 1 , 0 , 1 , 2 each with probability 1 / 5 1/5 1/5 . Find E [ X ] , V a r ( X ) E[X], \mathrm{Var}(X) E [ X ] , Var ( X ) .
A random variable has PMF P ( X = k ) = k / 10 P(X = k) = k/10 P ( X = k ) = k /10 for k = 1 , 2 , 3 , 4 k = 1, 2, 3, 4 k = 1 , 2 , 3 , 4 . Verify and find E [ X ] E[X] E [ X ] .
A gambler bets on red at roulette (P = 18 / 38 P = 18/38 P = 18/38 ). X X X = net gain per ₹100 100 100 bet. Find E [ X ] E[X] E [ X ] .
X X X has P ( X = − 1 ) = 1 / 2 , P ( X = 0 ) = 1 / 3 , P ( X = 1 ) = 1 / 6 P(X = -1) = 1/2, P(X = 0) = 1/3, P(X = 1) = 1/6 P ( X = − 1 ) = 1/2 , P ( X = 0 ) = 1/3 , P ( X = 1 ) = 1/6 . Find E [ X ] , E [ X 2 ] E[X], E[X^2] E [ X ] , E [ X 2 ] .
Two cards from a deck without replacement. X X X = number of aces. Find distribution, E [ X ] E[X] E [ X ] .
X X X uniform on { 1 , 2 , 3 , 4 , 5 } \{1, 2, 3, 4, 5\} { 1 , 2 , 3 , 4 , 5 } . Find E [ X ] , V a r ( X ) E[X], \mathrm{Var}(X) E [ X ] , Var ( X ) .
Y = 2 X + 5 Y = 2X + 5 Y = 2 X + 5 where X X X as in previous. Find E [ Y ] , V a r ( Y ) E[Y], \mathrm{Var}(Y) E [ Y ] , Var ( Y ) .
Verify V a r ( X ) = E [ X 2 ] − ( E [ X ] ) 2 \mathrm{Var}(X) = E[X^2] - (E[X])^2 Var ( X ) = E [ X 2 ] − ( E [ X ] ) 2 for X X X in any previous problem.
A random variable is positive with probability p p p and zero otherwise; positive values are uniform on { 1 , 2 , 3 } \{1, 2, 3\} { 1 , 2 , 3 } . Find E [ X ] E[X] E [ X ] in terms of p p p .
Pitfalls and tricks
Always verify ∑ p i = 1 \sum p_i = 1 ∑ p i = 1 . A common error is to compute probabilities that don't sum to 1.
Use linearity of expectation to avoid manipulating distributions. E [ X + Y ] = E [ X ] + E [ Y ] E[X + Y] = E[X] + E[Y] E [ X + Y ] = E [ X ] + E [ Y ] regardless of independence.
The shortcut V a r ( X ) = E [ X 2 ] − ( E [ X ] ) 2 \mathrm{Var}(X) = E[X^2] - (E[X])^2 Var ( X ) = E [ X 2 ] − ( E [ X ] ) 2 is easier than computing E [ ( X − μ ) 2 ] E[(X - \mu)^2] E [( X − μ ) 2 ] directly.
Variance is non-negative. If your computed variance is negative, you've made an error.
Standard deviation is in the same units as X X X ; variance is in squared units.