Quiz 2

Week 3.1: Expected Value

756 words
4 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Week 3.1: Expected Value > **Prerequisites:** Joint PMF ([Week 1.1: Joint Probability Mass Function (Joint PMF)](/notes/01-foundation-bsma1004-stats-2-week01-01-joint-pmf)), Functions of RVs ([Week 2.1: Functions of Random Variables](/notes/01-foundation-bsma1004-stats-2-week02-05-functions-of-rvs)) > **Cross-link...

Week 3.1: Expected Value

Prerequisites: Joint PMF (Week 1.1: Joint Probability Mass Function (Joint PMF)), Functions of RVs (Week 2.1: Functions of Random Variables) Cross-links: BSMA1002 (Stats 1) — expectation, BSMA3012 (Linear Stat Models) — moments Core question: What is the "average" or "central" value of a random variable?

1. Intuition: The Balancing Point

The expected value E[X]\mathbb{E}[X] is the probability-weighted average of all possible values of XX. It represents the "centre of mass" of the PMF.
Physical analogy: If you place weights equal to fX(x)f_X(x) at positions xx on a see-saw, the expected value is the balance point. Key facts:
  • E[X]\mathbb{E}[X] may not be a possible value of XX (e.g., 3.53.5 for a die).
  • E[X]\mathbb{E}[X] has the same units as XX.
  • Not all random variables have finite expectation.

2. Formal Definition

Definition (Expected value) For a discrete random variable XX with range TXT_X and PMF fXf_X:
>E[X]=tTXtfX(t),>> \mathbb{E}[X] = \sum_{t \in T_X} t \cdot f_X(t), >
provided the sum converges absolutely. Examples:
DistributionPMFE[X]\mathbb{E}[X]
Bernoulli( pp )px(1p)1xp^x(1-p)^{1-x} , x{0,1}x\in\{0,1\}pp
Binomial( n,pn,p )(nx)px(1p)nx\binom{n}{x}p^x(1-p)^{n-x}npnp
Geometric( pp )(1p)x1p(1-p)^{x-1}p , x=1,2,x=1,2,\dots1/p1/p
Poisson( λ\lambda )eλλx/x!e^{-\lambda}\lambda^x/x! , x=0,1,x=0,1,\dotsλ\lambda
Uniform {a,,b}\{a,\dots,b\}1/(ba+1)1/(b-a+1)(a+b)/2(a+b)/2

3. Expected Value of a Function: The LOTUS

The Law of the Unconscious Statistician (LOTUS) is a crucial result:
Theorem (LOTUS) For any function gg and random variable XX with PMF fXf_X:
>E[g(X)]=tTXg(t)fX(t).>> \mathbb{E}[g(X)] = \sum_{t \in T_X} g(t) \cdot f_X(t). >
For g(X1,,Xn)g(X_1,\dots,X_n) with joint PMF fX1Xnf_{X_1\dots X_n}:
>E[g(X1,,Xn)]=t1,,tng(t1,,tn)fX1Xn(t1,,tn).>> \mathbb{E}[g(X_1,\dots,X_n)] = \sum_{t_1,\dots,t_n} g(t_1,\dots,t_n) \cdot f_{X_1\dots X_n}(t_1,\dots,t_n). >
Why it matters: You don't need to find the PMF of g(X)g(X) first — just apply gg to each xx and use the original PMF.

Example

XUniform{2,1,0,1,2}X \sim \text{Uniform}\{-2,-1,0,1,2\}, g(X)=X2g(X) = X^2:
E[X2]=(2)215+(1)215+0215+1215+2215=4+1+0+1+45=2.\mathbb{E}[X^2] = (-2)^2\cdot\frac{1}{5} + (-1)^2\cdot\frac{1}{5} + 0^2\cdot\frac{1}{5} + 1^2\cdot\frac{1}{5} + 2^2\cdot\frac{1}{5} = \frac{4+1+0+1+4}{5} = 2.

4. Linearity of Expectation

Theorem (Linearity) For random variables X,YX,Y and constants a,ba,b:
>E[aX+bY]=aE[X]+bE[Y].>> \mathbb{E}[aX + bY] = a\mathbb{E}[X] + b\mathbb{E}[Y]. >
This holds whether or not XX and YY are independent — one of the most powerful properties in probability. Proof sketch:
E[aX+bY]=x,y(ax+by)fXY(x,y)=ax,yxfXY(x,y)+bx,yyfXY(x,y)=aE[X]+bE[Y].\begin{aligned} \mathbb{E}[aX + bY] &= \sum_{x,y} (ax + by) f_{XY}(x,y) \\ &= a\sum_{x,y} x f_{XY}(x,y) + b\sum_{x,y} y f_{XY}(x,y) \\ &= a\mathbb{E}[X] + b\mathbb{E}[Y]. \end{aligned}

Example: Expected value of Binomial via linearity

YBinomial(n,p)Y \sim \text{Binomial}(n,p). Write Y=i=1nXiY = \sum_{i=1}^n X_i where XiBernoulli(p)X_i \sim \text{Bernoulli}(p) i.i.d.
E[Y]=i=1nE[Xi]=i=1np=np.\mathbb{E}[Y] = \sum_{i=1}^n \mathbb{E}[X_i] = \sum_{i=1}^n p = np.
This is much simpler than summing k(nk)pk(1p)nkk\binom{n}{k}p^k(1-p)^{n-k} directly!

5. Expected Value of Independent Products

If XX and YY are independent:
>E[XY]=E[X]E[Y].>> \mathbb{E}[XY] = \mathbb{E}[X] \cdot \mathbb{E}[Y]. >
Proof: Using independence fXY(x,y)=fX(x)fY(y)f_{XY}(x,y) = f_X(x)f_Y(y):
E[XY]=x,yxyfX(x)fY(y)=(xxfX(x))(yyfY(y))=E[X]E[Y].\mathbb{E}[XY] = \sum_{x,y} xy f_X(x) f_Y(y) = \left(\sum_x x f_X(x)\right)\left(\sum_y y f_Y(y)\right) = \mathbb{E}[X]\mathbb{E}[Y].

6. Moments

Definition (Moments) The kk-th raw moment of XX is E[Xk]\mathbb{E}[X^k]. The kk-th central moment is E[(Xμ)k]\mathbb{E}[(X - \mu)^k], where μ=E[X]\mu = \mathbb{E}[X].
  • E[X]\mathbb{E}[X] = first raw moment (mean)
  • E[X2]\mathbb{E}[X^2] = second raw moment
  • Var(X)=E[X2](E[X])2\operatorname{Var}(X) = \mathbb{E}[X^2] - (\mathbb{E}[X])^2 = second central moment

7. Practice Questions

Q1 (Easy)

XX takes values {2,0,2,4}\{-2,0,2,4\} with probabilities {0.2,0.3,0.4,0.1}\{0.2, 0.3, 0.4, 0.1\}. Find E[X]\mathbb{E}[X].
Full Solution
E[X]=(2)(0.2)+0(0.3)+2(0.4)+4(0.1)=0.4+0+0.8+0.4=0.8\mathbb{E}[X] = (-2)(0.2) + 0(0.3) + 2(0.4) + 4(0.1) = -0.4 + 0 + 0.8 + 0.4 = 0.8.

Q2 (Medium)

XPoisson(4)X \sim \text{Poisson}(4). Find E[X2]\mathbb{E}[X^2].
Full Solution
For Poisson(λ\lambda): E[X]=λ\mathbb{E}[X] = \lambda, Var(X)=λ\operatorname{Var}(X) = \lambda.
Var(X)=E[X2](E[X])2    E[X2]=λ+λ2=4+16=20\operatorname{Var}(X) = \mathbb{E}[X^2] - (\mathbb{E}[X])^2 \implies \mathbb{E}[X^2] = \lambda + \lambda^2 = 4 + 16 = 20.

Q3 (Hard — LOTUS)

XUniform{1,2,3,4,5,6}X \sim \text{Uniform}\{1,2,3,4,5,6\}. Find E[X3]\mathbb{E}[X^3].
Full Solution
>E[X3]=16(13+23+33+43+53+63)=16(1+8+27+64+125+216)=4416=73.5.>> \mathbb{E}[X^3] = \frac{1}{6}(1^3 + 2^3 + 3^3 + 4^3 + 5^3 + 6^3) = \frac{1}{6}(1 + 8 + 27 + 64 + 125 + 216) = \frac{441}{6} = 73.5. >
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.