Math Lab
Home/Class XII/Ch 13/Random variables and expectation

Random variables and expectation

A random variable XX 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 XX: the list of possible values it can take, and their probabilities.

Definition

Formally, X:ΩRX : \Omega \to \mathbb{R} is a real-valued function on the sample space Ω\Omega.

For discrete random variables (the Class XII focus), XX takes finitely or countably many values x1,x2,x_1, x_2, \ldots. The probability mass function (PMF) gives the probability of each value: pi=P(X=xi),p_i = P(X = x_i), with ipi=1\sum_i p_i = 1.

Examples of random variables

  • X=X = number on a die: values {1,2,3,4,5,6}\{1, 2, 3, 4, 5, 6\}, each with probability 1/61/6.
  • X=X = number of heads in 3 coin flips: values {0,1,2,3}\{0, 1, 2, 3\}, probabilities 1/8,3/8,3/8,1/81/8, 3/8, 3/8, 1/8.
  • 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:

XXx1x_1x2x_2x3x_3\cdots
P(X)P(X)p1p_1p2p_2p3p_3\cdots

Always check: probabilities are non-negative and sum to 1.

Expectation

The expected value (or mean) of a discrete random variable XX is E[X]=μ=ixipi.E[X] = \mu = \sum_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] is the long-run average of XX.

Properties of expectation:

  • Linearity: E[aX+b]=aE[X]+bE[aX + b] = aE[X] + b.
  • For two random variables: E[X+Y]=E[X]+E[Y]E[X + Y] = E[X] + E[Y] (always, even if not independent).
  • For independent X,YX, Y: E[XY]=E[X]E[Y]E[XY] = E[X]\,E[Y].

Variance and standard deviation

The variance measures spread: Var(X)=σ2=E[(Xμ)2]=i(xiμ)2pi.\mathrm{Var}(X) = \sigma^2 = E[(X - \mu)^2] = \sum_i (x_i - \mu)^2 p_i.

A useful computational form: Var(X)=E[X2](E[X])2.\mathrm{Var}(X) = E[X^2] - (E[X])^2.

The standard deviation is σ=Var(X)\sigma = \sqrt{\mathrm{Var}(X)}, in the same units as XX.

Properties:

  • Var(aX+b)=a2Var(X)\mathrm{Var}(aX + b) = a^2\,\mathrm{Var}(X). (Shifts don't affect spread; scaling squares.)
  • For independent X,YX, Y: Var(X+Y)=Var(X)+Var(Y)\mathrm{Var}(X + Y) = \mathrm{Var}(X) + \mathrm{Var}(Y).

Worked examples

Example 1. XX = score on a fair die. Find E[X]E[X] and Var(X)\mathrm{Var}(X).

E[X]=(1+2+3+4+5+6)/6=21/6=7/2=3.5E[X] = (1 + 2 + 3 + 4 + 5 + 6)/6 = 21/6 = 7/2 = 3.5.

E[X2]=(1+4+9+16+25+36)/6=91/6E[X^2] = (1 + 4 + 9 + 16 + 25 + 36)/6 = 91/6.

Var(X)=91/6(7/2)2=91/649/4=182/12147/12=35/122.917\mathrm{Var}(X) = 91/6 - (7/2)^2 = 91/6 - 49/4 = 182/12 - 147/12 = 35/12 \approx 2.917.

Example 2. Two coins are flipped. XX = number of heads. Find the distribution, E[X]E[X], Var(X)\mathrm{Var}(X).

XX012
PP1/41/21/4

E[X]=0(1/4)+1(1/2)+2(1/4)=1E[X] = 0(1/4) + 1(1/2) + 2(1/4) = 1.

E[X2]=0+1(1/2)+4(1/4)=3/2E[X^2] = 0 + 1(1/2) + 4(1/4) = 3/2.

Var(X)=3/21=1/2\mathrm{Var}(X) = 3/2 - 1 = 1/2.

Example 3. A coin is flipped repeatedly until heads appears (or until 4 flips). Let XX = number of flips. Find the distribution.

X=1X = 1: heads on first flip, P=1/2P = 1/2. X=2X = 2: TH, P=1/4P = 1/4. X=3X = 3: TTH, P=1/8P = 1/8. X=4X = 4: TTTH or TTTT, P=1/16+1/16=1/8P = 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=4X = 4" by our definition. So P(X=4)=1/16+1/16=1/8P(X = 4) = 1/16 + 1/16 = 1/8. Check sum: 1/2+1/4+1/8+1/8=11/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/8E[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 XX = number of white balls. Find distribution and mean.

X=0X = 0: both black. P=(22)/(62)=1/15P = \binom{2}{2}/\binom{6}{2} = 1/15. X=1X = 1: one of each. P=(41)(21)/(62)=8/15P = \binom{4}{1}\binom{2}{1}/\binom{6}{2} = 8/15. X=2X = 2: both white. P=(42)/(62)=6/15P = \binom{4}{2}/\binom{6}{2} = 6/15.

Check: 1/15+8/15+6/15=15/151/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/3E[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 ₹1010. Probability of winning ₹10001000 is 0.0050.005; otherwise nothing. Find the expected net gain.

XX = net gain. X=10X = -10 with probability 0.9950.995 (lose ₹10), X=990X = 990 with probability 0.0050.005 (win ₹1000 minus ₹10 spent).

E[X]=10(0.995)+990(0.005)=9.95+4.95=5E[X] = -10(0.995) + 990(0.005) = -9.95 + 4.95 = -5. Expected loss of ₹5.

Example 6. A random variable XX takes values 1,2,31, 2, 3 with probabilities 1/6,1/3,1/21/6, 1/3, 1/2. Find E[X],E[X2],Var(X)E[X], E[X^2], \mathrm{Var}(X).

E[X]=1(1/6)+2(1/3)+3(1/2)=1/6+4/6+9/6=14/6=7/3E[X] = 1(1/6) + 2(1/3) + 3(1/2) = 1/6 + 4/6 + 9/6 = 14/6 = 7/3.

E[X2]=1(1/6)+4(1/3)+9(1/2)=1/6+8/6+27/6=36/6=6E[X^2] = 1(1/6) + 4(1/3) + 9(1/2) = 1/6 + 8/6 + 27/6 = 36/6 = 6.

Var(X)=649/9=54/949/9=5/9\mathrm{Var}(X) = 6 - 49/9 = 54/9 - 49/9 = 5/9.

Try it yourself

  1. XX = number of heads in 4 fair coin flips. Find the distribution, E[X],Var(X)E[X], \mathrm{Var}(X).
  2. A die is rolled; XX = score if even, 00 if odd. Find E[X]E[X].
  3. XX = sum of two dice. Find E[X]E[X] and Var(X)\mathrm{Var}(X).
  4. A box has 5 R, 3 B balls. Two drawn without replacement; XX = red balls. Find distribution and E[X]E[X].
  5. Three coins. XX = number of tails. Find E[X],Var(X)E[X], \mathrm{Var}(X).
  6. XX takes values 2,1,0,1,2-2, -1, 0, 1, 2 each with probability 1/51/5. Find E[X],Var(X)E[X], \mathrm{Var}(X).
  7. A random variable has PMF P(X=k)=k/10P(X = k) = k/10 for k=1,2,3,4k = 1, 2, 3, 4. Verify and find E[X]E[X].
  8. A gambler bets on red at roulette (P=18/38P = 18/38). XX = net gain per ₹100100 bet. Find E[X]E[X].
  9. XX has P(X=1)=1/2,P(X=0)=1/3,P(X=1)=1/6P(X = -1) = 1/2, P(X = 0) = 1/3, P(X = 1) = 1/6. Find E[X],E[X2]E[X], E[X^2].
  10. Two cards from a deck without replacement. XX = number of aces. Find distribution, E[X]E[X].
  11. XX uniform on {1,2,3,4,5}\{1, 2, 3, 4, 5\}. Find E[X],Var(X)E[X], \mathrm{Var}(X).
  12. Y=2X+5Y = 2X + 5 where XX as in previous. Find E[Y],Var(Y)E[Y], \mathrm{Var}(Y).
  13. Verify Var(X)=E[X2](E[X])2\mathrm{Var}(X) = E[X^2] - (E[X])^2 for XX in any previous problem.
  14. A random variable is positive with probability pp and zero otherwise; positive values are uniform on {1,2,3}\{1, 2, 3\}. Find E[X]E[X] in terms of pp.

Pitfalls and tricks

  • Always verify pi=1\sum 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] regardless of independence.
  • The shortcut Var(X)=E[X2](E[X])2\mathrm{Var}(X) = E[X^2] - (E[X])^2 is easier than computing E[(Xμ)2]E[(X - \mu)^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 XX; variance is in squared units.

Practice quiz

Quick check on this topic.

Quiz
Quick check : Random variables and expectation
6 questions · pick the best answer
Q1

Sum of probabilities in a PMF equals

Q2

E[X]E[X] for fair die is

Q3

Var(X)=E[(Xμ)2]\mathrm{Var}(X) = E[(X - \mu)^2] equivalently equals

Q4

Linearity: E[aX+b]=E[aX + b] =

Q5

For independent X,YX, Y: Var(X+Y)=\mathrm{Var}(X + Y) =

Q6

If XX takes values 0,1,20, 1, 2 with probabilities 1/4,1/2,1/41/4, 1/2, 1/4, then E[X]=E[X] =