Quiz 2

Expectation and Variance — Properties and Applications

2418 words
12 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

# Expectation and Variance — Properties and Applications ## 🎯 Learning Objectives After completing this topic, you will be able to: - Apply **linearity of expectation** $E(aX + bY) = aE(X) + bE(Y)$ - Compute $E(g(X))$ for various functions g - Understand the **variance** formula and its properties - Compute **covar...

Expectation and Variance — Properties and Applications

🎯 Learning Objectives

After completing this topic, you will be able to:
  • Apply linearity of expectation E(aX+bY)=aE(X)+bE(Y)E(aX + bY) = aE(X) + bE(Y)
  • Compute E(g(X))E(g(X)) for various functions g
  • Understand the variance formula and its properties
  • Compute covariance and understand its relationship to variance
  • Apply these concepts to portfolio theory and decision making

📋 Prerequisites


📖 Core Content

18.1 Intuition: Why Expectation Properties Matter

The expected value E(X)E(X) isn't just a formula — it's an operator with powerful properties. These properties let us:
  • Compute expected values of complex expressions without starting from scratch
  • Understand how random variables combine (sums, products, etc.)
  • Simplify calculations dramatically
Everyday analogy: If you know the expected return of stocks and bonds separately, linearity of expectation tells you the expected return of a portfolio that combines them. 🔑 Key Insight: Expectation is linear, but variance is NOT. This distinction is crucial.

18.2 Properties of Expected Value

18.2.1 Constants

E(c)=cE(c) = c
The expected value of a constant is the constant itself.

18.2.2 Linearity (The Most Important Property)

E(aX+bY)=aE(X)+bE(Y)E(aX + bY) = aE(X) + bE(Y)
This is true regardless of whether X and Y are independent! Generalized: E(a1X1+a2X2+...+anXn)=a1E(X1)+a2E(X2)+...+anE(Xn)E(a_1X_1 + a_2X_2 + ... + a_nX_n) = a_1E(X_1) + a_2E(X_2) + ... + a_nE(X_n)

18.2.3 Expected Value of a Function

E(g(X))={g(x)p(x)(discrete)g(x)f(x)dx(continuous)E(g(X)) = \begin{cases} \sum g(x) \cdot p(x) & \text{(discrete)} \\ \int g(x) \cdot f(x) \, dx & \text{(continuous)} \end{cases}
Important: E(g(X))g(E(X))E(g(X)) \neq g(E(X)) in general. This is Jensen's inequality — for convex functions, E(g(X))g(E(X))E(g(X)) \geq g(E(X)).

18.3 Properties of Variance

18.3.1 Definition

Var(X)=E[(Xμ)2]=E(X2)[E(X)]2Var(X) = E[(X - \mu)^2] = E(X^2) - [E(X)]^2

18.3.2 Constant

Var(c)=0Var(c) = 0

18.3.3 Linear Transformation

Var(aX+b)=a2Var(X)Var(aX + b) = a^2 Var(X)
Note: Adding a constant b doesn't change variance. Multiplying by a multiplies variance by a2a^2.

18.3.4 Sum of Two Variables

Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)Var(X + Y) = Var(X) + Var(Y) + 2Cov(X, Y)
If X and Y are independent, Cov(X,Y)=0Cov(X, Y) = 0, so:
Var(X+Y)=Var(X)+Var(Y)Var(X + Y) = Var(X) + Var(Y)

18.3.5 Difference of Two Variables

Var(XY)=Var(X)+Var(Y)2Cov(X,Y)Var(X - Y) = Var(X) + Var(Y) - 2Cov(X, Y)
If X and Y are independent:
Var(XY)=Var(X)+Var(Y)Var(X - Y) = Var(X) + Var(Y)
Note: Variances ADD even when subtracting! Var(XY)=Var(X)+Var(Y)Var(X - Y) = Var(X) + Var(Y) for independent X, Y.

18.4 Covariance

18.4.1 Definition

Cov(X,Y)=E[(XμX)(YμY)]=E(XY)E(X)E(Y)\text{Cov}(X, Y) = E[(X - \mu_X)(Y - \mu_Y)] = E(XY) - E(X)E(Y)

18.4.2 Interpretation

  • Positive covariance: X and Y tend to move in the same direction
  • Negative covariance: X and Y tend to move in opposite directions
  • Zero covariance: No linear relationship (but could still have non-linear dependence!)

18.4.3 Properties

  1. Cov(X,Y)=Cov(Y,X)Cov(X, Y) = Cov(Y, X) (symmetric)
  2. Cov(X,X)=Var(X)Cov(X, X) = Var(X)
  3. Cov(aX,bY)=abCov(X,Y)Cov(aX, bY) = ab \cdot Cov(X, Y)
  4. Cov(X+Y,Z)=Cov(X,Z)+Cov(Y,Z)Cov(X + Y, Z) = Cov(X, Z) + Cov(Y, Z)

18.5 Correlation Coefficient

ρ(X,Y)=Cov(X,Y)σXσY\rho(X, Y) = \frac{Cov(X, Y)}{\sigma_X \sigma_Y}
Properties:
  • 1ρ1-1 \leq \rho \leq 1
  • ρ=±1\rho = \pm 1 means perfect linear relationship
  • ρ=0\rho = 0 means no linear relationship
  • Unitless (unlike covariance)

18.6 Worked Examples

Example 1: Linearity of Expectation (Easy)

Scenario: E(X)=10E(X) = 10, E(Y)=20E(Y) = 20. Find E(2X+3Y5)E(2X + 3Y - 5). Solution:
E(2X+3Y5)=2E(X)+3E(Y)5=2(10)+3(20)5=20+605=75E(2X + 3Y - 5) = 2E(X) + 3E(Y) - 5 = 2(10) + 3(20) - 5 = 20 + 60 - 5 = 75

Example 2: Variance of a Linear Combination (Medium)

Scenario: Var(X)=4Var(X) = 4, Var(Y)=9Var(Y) = 9, Cov(X,Y)=2Cov(X, Y) = 2. Find Var(2XY+3)Var(2X - Y + 3). Solution: Var(2XY+3)=Var(2XY)Var(2X - Y + 3) = Var(2X - Y) (adding constant doesn't change variance) =Var(2X)+Var(Y)+2Cov(2X,Y)= Var(2X) + Var(-Y) + 2Cov(2X, -Y) =4Var(X)+Var(Y)+2×2×(1)×Cov(X,Y)= 4Var(X) + Var(Y) + 2 \times 2 \times (-1) \times Cov(X, Y) =4(4)+9+(4)(2)=16+98=17= 4(4) + 9 + (-4)(2) = 16 + 9 - 8 = 17

Example 3: Portfolio Risk (Harder)

Scenario: Stock A: E(RA)=8%E(R_A) = 8\%, σA=15%\sigma_A = 15\%. Stock B: E(RB)=12%E(R_B) = 12\%, σB=20%\sigma_B = 20\%. ρAB=0.3\rho_{AB} = 0.3. A portfolio invests 40% in A, 60% in B. Find: a) Expected portfolio return, b) Portfolio variance Solution: a) Expected return:
E(RP)=0.4(8%)+0.6(12%)=3.2%+7.2%=10.4%E(R_P) = 0.4(8\%) + 0.6(12\%) = 3.2\% + 7.2\% = 10.4\%
b) Portfolio variance:
Var(RP)=Var(0.4A+0.6B)Var(R_P) = Var(0.4A + 0.6B) =0.42Var(A)+0.62Var(B)+2(0.4)(0.6)Cov(A,B)= 0.4^2Var(A) + 0.6^2Var(B) + 2(0.4)(0.6)Cov(A,B)
Cov(A,B)=ρσAσB=0.3×15×20=90Cov(A,B) = \rho \sigma_A \sigma_B = 0.3 \times 15 \times 20 = 90 (in %² units)
Var(RP)=0.16(225)+0.36(400)+2(0.24)(90)Var(R_P) = 0.16(225) + 0.36(400) + 2(0.24)(90) =36+144+43.2=223.2= 36 + 144 + 43.2 = 223.2 σP=223.214.94%\sigma_P = \sqrt{223.2} \approx 14.94\%
Interpretation: The portfolio has expected return 10.4% with risk 14.94%. This is better risk-adjusted than either stock alone due to diversification.

18.7 Moment Generating Functions (Brief Intro)

The k-th moment of X is E(Xk)E(X^k):
  • 1st moment = mean
  • 2nd moment about mean = variance The moment generating function (MGF) MX(t)=E(etX)M_X(t) = E(e^{tX}) generates all moments. We'll use this in BSMA1004.

18.8 Chebyshev's Inequality

For ANY distribution with finite mean μ and variance σ²:
P(Xμkσ)1k2P(|X - \mu| \geq k\sigma) \leq \frac{1}{k^2}
Example: For k = 2: at most 25% of values are more than 2 s.d. from the mean. Useful when: The distribution is not normal and we can't use the empirical rule.

18.9 Decision Theory Applications

Expected value is central to decision making under uncertainty: Expected Monetary Value (EMV): Choose the option with highest E(profit)E(\text{profit}). Example:
DecisionProfit if Good Economy (P=0.6)Profit if Bad Economy (P=0.4)
Expand₹10 Cr-₹2 Cr
Stay₹4 Cr₹1 Cr
Contract-₹1 Cr₹3 Cr
E(Expand)=10(0.6)+(2)(0.4)=60.8=5.2E(\text{Expand}) = 10(0.6) + (-2)(0.4) = 6 - 0.8 = 5.2 Cr E(Stay)=4(0.6)+1(0.4)=2.4+0.4=2.8E(\text{Stay}) = 4(0.6) + 1(0.4) = 2.4 + 0.4 = 2.8 Cr E(Contract)=1(0.6)+3(0.4)=0.6+1.2=0.6E(\text{Contract}) = -1(0.6) + 3(0.4) = -0.6 + 1.2 = 0.6 Cr Best decision: Expand (highest EMV = 5.2 Cr).

📐 Key Formulas / Concepts

ConceptFormulaNotes
LinearityE(aX+bY)=aE(X)+bE(Y)E(aX+bY) = aE(X)+bE(Y)Always true
E(g(X))E(g(X))g(x)p(x)\sum g(x)p(x) or g(x)f(x)dx\int g(x)f(x)dxLaw of the Unconscious Statistician
Var(aX+b)Var(aX+b)a2Var(X)a^2 Var(X)Constant doesn't affect variance
Var(X+Y)Var(X+Y)Var(X)+Var(Y)+2Cov(X,Y)Var(X)+Var(Y)+2Cov(X,Y)Reduces to sum if independent
CovarianceE(XY)E(X)E(Y)E(XY) - E(X)E(Y)Measures linear dependence
Correlationρ=Cov(X,Y)/(σXσY)\rho = Cov(X,Y)/(\sigma_X\sigma_Y)Unitless, -1 to 1
Chebyshev$P(X-\mu

⚠️ Common Pitfalls

Pitfall 1: Assuming E(g(X))=g(E(X))E(g(X)) = g(E(X))

The mistake: Thinking E(X2)=[E(X)]2E(X^2) = [E(X)]^2. Why it happens: It would be convenient, so students assume it. Correction: E(X2)[E(X)]2E(X^2) \geq [E(X)]^2. The difference IS the variance.

Pitfall 2: Adding Variances Instead of Standard Deviations

The mistake: Adding standard deviations: σX+Y=σX+σY\sigma_{X+Y} = \sigma_X + \sigma_Y. Correction: For independent variables, Var(X+Y)=Var(X)+Var(Y)Var(X+Y) = Var(X) + Var(Y), so σX+Y=σX2+σY2\sigma_{X+Y} = \sqrt{\sigma_X^2 + \sigma_Y^2}. Standard deviations don't add directly.

Pitfall 3: Forgetting Covariance in Variance of Sums

The mistake: Var(X+Y)=Var(X)+Var(Y)Var(X+Y) = Var(X) + Var(Y) when X and Y are dependent. Correction: The full formula includes 2Cov(X,Y)2Cov(X,Y). Only independent variables have covariance = 0.

📝 Practice Questions

Q1: Linearity
</strong>
E(X)=5E(X) = 5, E(Y)=2E(Y) = -2. Find E(3X2Y+7)E(3X - 2Y + 7).
<details> <strong>Solution</strong>
E(3X2Y+7)=3E(X)2E(Y)+7=3(5)2(2)+7=15+4+7=26E(3X - 2Y + 7) = 3E(X) - 2E(Y) + 7 = 3(5) - 2(-2) + 7 = 15 + 4 + 7 = 26
26\boxed{26}
</details> > **Q2: Variance of Sum** > > </strong> > > $Var(X) = 9$, $Var(Y) = 16$, $Cov(X,Y) = 4$. Find $Var(X+Y)$. > > <details> <strong>Solution</strong> > > $Var(X+Y) = 9 + 16 + 2(4) = 9 + 16 + 8 = 33$ > > $\boxed{33}$ </details> > **Q3: Covariance Calculation** > > </strong> > > Joint distribution of X and Y: > >
Y=0Y=1Y=2
X=00.10.20
X=10.10.30.3
Find Cov(X,Y)Cov(X,Y).
<details> <strong>Solution</strong>
Marginal PMFs: P(X=0)=0.1+0.2+0=0.3P(X=0) = 0.1+0.2+0 = 0.3, P(X=1)=0.1+0.3+0.3=0.7P(X=1) = 0.1+0.3+0.3 = 0.7 E(X)=0(0.3)+1(0.7)=0.7E(X) = 0(0.3) + 1(0.7) = 0.7
P(Y=0)=0.1+0.1=0.2P(Y=0) = 0.1+0.1 = 0.2, P(Y=1)=0.2+0.3=0.5P(Y=1) = 0.2+0.3 = 0.5, P(Y=2)=0+0.3=0.3P(Y=2) = 0+0.3 = 0.3 E(Y)=0(0.2)+1(0.5)+2(0.3)=0+0.5+0.6=1.1E(Y) = 0(0.2) + 1(0.5) + 2(0.3) = 0 + 0.5 + 0.6 = 1.1
E(XY)=xyp(x,y)E(XY) = \sum\sum xy \cdot p(x,y) =0(0)(0.1)+0(1)(0.2)+0(2)(0)+1(0)(0.1)+1(1)(0.3)+1(2)(0.3)= 0(0)(0.1) + 0(1)(0.2) + 0(2)(0) + 1(0)(0.1) + 1(1)(0.3) + 1(2)(0.3) =0+0+0+0+0.3+0.6=0.9= 0 + 0 + 0 + 0 + 0.3 + 0.6 = 0.9
Cov(X,Y)=0.9(0.7)(1.1)=0.90.77=0.13Cov(X,Y) = 0.9 - (0.7)(1.1) = 0.9 - 0.77 = 0.13
Cov(X,Y)=0.13\boxed{Cov(X,Y) = 0.13}
</details> > **Q4: Correlation** > > </strong> > > Using Q3, find $\rho(X,Y)$ if $Var(X) = 0.21$ and $Var(Y) = 0.49$. > > <details> <strong>Solution</strong> > > $\rho = \frac{0.13}{\sqrt{0.21} \times \sqrt{0.49}} = \frac{0.13}{0.458 \times 0.7} = \frac{0.13}{0.321} \approx 0.405$ > > There's a moderate positive correlation. > > $\boxed{\rho \approx 0.405}$ </details> > **Q5: Chebyshev's Inequality** > > A distribution has mean 100 and standard deviation 15. Use Chebyshev to find the minimum percentage of data within 70 to 130. > > <details> <strong>Solution</strong> > > 70 and 130 are 30 units from the mean. 30/15 = 2 standard deviations. > > $k = 2$, so at most $1/2^2 = 1/4 = 25\%$ of data is more than 2 s.d. away. > > Therefore, at least $1 - 1/4 = 75\%$ of data falls within 70 to 130. > > **Better than Chebyshev?** If the distribution is known to be approximately normal, the empirical rule gives 95%. But Chebyshev works for ANY distribution. > > $\boxed{\text{At least } 75\%}$ </details> > **Q6: Portfolio Diversification** > > </strong> > > Two assets: $Var(A) = 100$, $Var(B) = 400$, $\rho = -0.5$. Find the portfolio weight w that minimizes variance for a portfolio $P = wA + (1-w)B$. > > <details> <strong>Solution</strong> > > $Var(P) = w^2(100) + (1-w)^2(400) + 2w(1-w)(-0.5)(\sqrt{100}\sqrt{400})$ > > $= 100w^2 + 400(1 - 2w + w^2) + 2w(1-w)(-0.5)(200)$ > > $= 100w^2 + 400 - 800w + 400w^2 + 2w(1-w)(-100)$ > > $= 100w^2 + 400 - 800w + 400w^2 - 200w(1-w)$ > > $= 500w^2 - 800w + 400 - 200w + 200w^2$ > > $= 700w^2 - 1000w + 400$ > > **Minimize:** Differentiate and set to 0: $1400w - 1000 = 0$ $w = 1000/1400 = 5/7 \approx 0.714$ > > So invest about 71.4% in A and 28.6% in B for minimum variance. > > $\boxed{w = 5/7 \approx 0.714}$ </details> > **Q7: Expected Value of Dice Game** > > Roll a fair die. You win ₹10 if you get a 6, otherwise you roll again. If you roll again, you win ₹4 if you get 4-6, ₹1 if you get 1-3. Find the expected winnings. > > <details> <strong>Solution</strong> > > **Strategy:** First roll: > > - P(6) = 1/6, win ₹10. > - P(not 6) = 5/6, go to second roll. > > **Second roll (given we got here):** > > - P(4-6) = 3/6 = 1/2, win ₹4 > - P(1-3) = 3/6 = 1/2, win ₹1 > > $E(\text{second roll}) = 4(1/2) + 1(1/2) = 2.5$ > > **Overall:** $E(X) = 10(1/6) + 2.5(5/6) = 10/6 + 12.5/6 = 22.5/6 = 3.75$ > > Expected winnings are ₹3.75. > > $\boxed{₹3.75}$ </details> > **Q8: Decision Tree** > > A company can develop Product A (cost ₹2M, revenue depends on demand) or Product B (cost ₹1M). For Product A, high demand (P=0.7) gives ₹10M revenue, low demand gives ₹1M. For Product B, high demand (P=0.4) gives ₹5M revenue, low demand gives ₹0.5M. Which product maximizes expected profit? > > <details> <strong>Solution</strong> > > **Product A:** $E(\text{revenue}) = 10(0.7) + 1(0.3) = 7 + 0.3 = 7.3$M $E(\text{profit}) = 7.3 - 2 = 5.3$M > > **Product B:** $E(\text{revenue}) = 5(0.4) + 0.5(0.6) = 2 + 0.3 = 2.3$M $E(\text{profit}) = 2.3 - 1 = 1.3$M > > **Product A** has higher expected profit (5.3M vs 1.3M). > > But Product A is riskier — could lose 1M (if low demand, revenue 1M minus cost 2M). Risk-averse decision-makers might prefer Product B. > > $\boxed{\text{Product A: } ₹5.3\text{M expected profit}}$ </details> > **Q9: Variance of Sample Mean** > > $X_1, X_2, ..., X_n$ are independent with $E(X_i) = \mu$ and $Var(X_i) = \sigma^2$. > > Find $E(\bar{X})$ and $Var(\bar{X})$ where $\bar{X} = \frac{1}{n}\sum_{i=1}^n X_i$. > > <details> <strong>Solution</strong> > > **Mean of sample mean:** $E(\bar{X}) = E\left(\frac{1}{n}\sum X_i\right) = \frac{1}{n}\sum E(X_i) = \frac{1}{n}(n\mu) = \mu$ > > The sample mean is an **unbiased estimator** of the population mean. > > **Variance of sample mean:** $Var(\bar{X}) = Var\left(\frac{1}{n}\sum X_i\right) = \frac{1}{n^2}\sum Var(X_i) = \frac{1}{n^2}(n\sigma^2) = \frac{\sigma^2}{n}$ > > **Key insight:** The variance of the sample mean decreases as sample size increases. This is why larger samples give more precise estimates. > > $\boxed{E(\bar{X}) = \mu,\ Var(\bar{X}) = \sigma^2/n}$ </details> > **Q10: Application — Insurance Risk** > > An insurance company sells 10,000 policies. Each policy has: > > - P(no claim) = 0.9, profit = ₹1000 > - P(small claim) = 0.08, profit = ₹-5000 > - P(large claim) = 0.02, profit = ₹-20,000 > > Policies are independent. Find the expected total profit and the standard deviation. > > <details> <strong>Solution</strong> > > Let $X_i$ = profit from policy i. > > $E(X_i) = 1000(0.9) + (-5000)(0.08) + (-20000)(0.02)$ $= 900 - 400 - 400 = 100$ > > $E(X_i^2) = 1000^2(0.9) + (-5000)^2(0.08) + (-20000)^2(0.02)$ $= 900,000 + 2,000,000 + 8,000,000 = 10,900,000$ > > $Var(X_i) = 10,900,000 - 100^2 = 10,900,000 - 10,000 = 10,890,000$ > > **Total profit:** $T = \sum_{i=1}^{10000} X_i$ > > $E(T) = 10,000 \times 100 = ₹1,000,000$ > > $Var(T) = 10,000 \times 10,890,000 = 108,900,000,000$ > > $\sigma_T = \sqrt{108,900,000,000} \approx ₹330,000$ > > **Interpretation:** The expected profit is ₹10 lakh, with a standard deviation of about ₹3.3 lakh. The insurance company is very likely to be profitable (profit is many standard deviations above zero). > > $\boxed{E(T) = ₹10,00,000,\ \sigma_T \approx ₹3,30,000}$ </details> * * * ## 🔗 Cross-References - **Next topic:** [Bernoulli & Binomial Distribution](/courses/bsma1002/notes/19-bernoulli-binomial) — the first named distribution - **Previous:** [Discrete & Continuous RVs](/notes/01-foundation-bsma1002-stats-1-week09-15-discrete-random-variables) — foundation for expectations - **Week 11 (Distributions):** All distributions have specific mean and variance formulas - **BSMA1004 (Stats 2):** Law of Large Numbers, Central Limit Theorem - **BSCS2004 (ML Foundations):** Cost functions as expectations, bias-variance tradeoff [Join Discord](https://discord.gg/gE2m4Qrdqv) [Previous**Continuous Random Variables**](/notes/01-foundation-bsma1002-stats-1-week09-16-continuous-random-variables)[Next**Bernoulli & Binomial**](/notes/01-foundation-bsma1002-stats-1-week11-18-bernoulli-binomial)
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.