Week 4.3: Expectations for Continuous Random Variables

504 words
3 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 4.3: Expectations for Continuous Random Variables > **Prerequisites:** Continuous RVs ([Week 4.1: Continuous Random Variables & PDFs](/notes/01-foundation-bsma1004-stats-2-week04-12-continuous-rvs-pdf)), Expectation discrete ([Week 3.1: Expected Value](/notes/01-foundation-bsma1004-stats-2-week03-08-expectati...

Week 4.3: Expectations for Continuous Random Variables

Prerequisites: Continuous RVs (Week 4.1: Continuous Random Variables & PDFs), Expectation discrete (Week 3.1: Expected Value) Core question: How do we compute means, variances, and expectations for continuous RVs?

1. From Sums to Integrals

For discrete RVs: E[X]=∑tt⋅fX(t)\mathbb{E}[X] = \sum_t t \cdot f_X(t). For continuous RVs: E[X]=∫−∞∞x⋅fX(x) dx\mathbb{E}[X] = \int_{-\infty}^\infty x \cdot f_X(x) \, dx. Everything works by replacing sums with integrals.

2. Definition

Definition (Expectation for continuous RVs) If XX has PDF fXf_X, then:
>E[X]=∫−∞∞xfX(x) dx,>> \mathbb{E}[X] = \int_{-\infty}^\infty x f_X(x) \, dx, >
provided ∫∣x∣fX(x) dx<∞\int |x| f_X(x) \, dx < \infty. LOTUS (continuous version):
E[g(X)]=∫−∞∞g(x)fX(x) dx.\mathbb{E}[g(X)] = \int_{-\infty}^\infty g(x) f_X(x) \, dx.

3. Key Properties (Same as Discrete!)

  1. Linearity: E[aX+bY]=aE[X]+bE[Y]\mathbb{E}[aX + bY] = a\mathbb{E}[X] + b\mathbb{E}[Y]
  2. Variance: Var⁡(X)=E[X2]−(E[X])2\operatorname{Var}(X) = \mathbb{E}[X^2] - (\mathbb{E}[X])^2
  3. If XX and YY independent: E[XY]=E[X]E[Y]\mathbb{E}[XY] = \mathbb{E}[X]\mathbb{E}[Y]

4. Examples

Example 1: Uniform(0,1)(0,1)

fX(x)=1f_X(x) = 1, 0≤x≤10 \leq x \leq 1. E[X]=∫01x⋅1 dx=[x2/2]01=1/2\mathbb{E}[X] = \int_0^1 x \cdot 1 \, dx = [x^2/2]_0^1 = 1/2. E[X2]=∫01x2 dx=[x3/3]01=1/3\mathbb{E}[X^2] = \int_0^1 x^2 \, dx = [x^3/3]_0^1 = 1/3. Var⁡(X)=1/3−(1/2)2=1/3−1/4=1/12\operatorname{Var}(X) = 1/3 - (1/2)^2 = 1/3 - 1/4 = 1/12.

Example 2: Exponential(λ)(\lambda)

fX(x)=λe−λxf_X(x) = \lambda e^{-\lambda x}, x≥0x \geq 0. E[X]=∫0∞xλe−λx dx=1λ\mathbb{E}[X] = \int_0^\infty x \lambda e^{-\lambda x} \, dx = \frac{1}{\lambda} (using integration by parts or Gamma integral). E[X2]=∫0∞x2λe−λx dx=2λ2\mathbb{E}[X^2] = \int_0^\infty x^2 \lambda e^{-\lambda x} \, dx = \frac{2}{\lambda^2}. Var⁡(X)=2λ2−(1λ)2=1λ2\operatorname{Var}(X) = \frac{2}{\lambda^2} - \left(\frac{1}{\lambda}\right)^2 = \frac{1}{\lambda^2}.

Example 3: fX(x)=38x2f_X(x) = \frac{3}{8}x^2, 0≤x≤20 \leq x \leq 2.

E[X]=∫02x⋅38x2 dx=38∫02x3 dx=38⋅164=38⋅4=32\mathbb{E}[X] = \int_0^2 x \cdot \frac{3}{8}x^2 \, dx = \frac{3}{8} \int_0^2 x^3 \, dx = \frac{3}{8} \cdot \frac{16}{4} = \frac{3}{8} \cdot 4 = \frac{3}{2}. E[X2]=∫02x2⋅38x2 dx=38∫02x4 dx=38⋅325=125\mathbb{E}[X^2] = \int_0^2 x^2 \cdot \frac{3}{8}x^2 \, dx = \frac{3}{8} \int_0^2 x^4 \, dx = \frac{3}{8} \cdot \frac{32}{5} = \frac{12}{5}. Var⁡(X)=125−(32)2=125−94=48−4520=320\operatorname{Var}(X) = \frac{12}{5} - \left(\frac{3}{2}\right)^2 = \frac{12}{5} - \frac{9}{4} = \frac{48-45}{20} = \frac{3}{20}.

5. Practice Questions

Q1 (Easy)

X∼Uniform(−1,3)X \sim \text{Uniform}(-1, 3). Find E[X]\mathbb{E}[X] and Var⁡(X)\operatorname{Var}(X).
Full Solution
E[X]=(−1+3)/2=1\mathbb{E}[X] = (-1+3)/2 = 1. Var⁡(X)=(3−(−1))2/12=16/12=4/3\operatorname{Var}(X) = (3-(-1))^2/12 = 16/12 = 4/3.

Q2 (Medium)

PDF: fX(x)=2e−2xf_X(x) = 2e^{-2x}, x≥0x \geq 0. Find E[X2]\mathbb{E}[X^2].
Full Solution
This is Exponential(2)(2). E[X2]=2/λ2=2/4=1/2\mathbb{E}[X^2] = 2/\lambda^2 = 2/4 = 1/2.

Q3 (Hard)

XX has PDF fX(x)=cx(1−x)f_X(x) = cx(1-x), 0≤x≤10 \leq x \leq 1. Find cc, E[X]\mathbb{E}[X], Var⁡(X)\operatorname{Var}(X).
Full Solution
1=∫01cx(1−x)dx=c∫01(x−x2)dx=c[x2/2−x3/3]01=c(1/2−1/3)=c/6  ⟹  c=61 = \int_0^1 cx(1-x)dx = c\int_0^1 (x-x^2)dx = c[x^2/2 - x^3/3]_0^1 = c(1/2-1/3) = c/6 \implies c=6.
E[X]=6∫01x2(1−x)dx=6∫01(x2−x3)dx=6[1/3−1/4]=6(1/12)=1/2\mathbb{E}[X] = 6\int_0^1 x^2(1-x)dx = 6\int_0^1 (x^2-x^3)dx = 6[1/3-1/4] = 6(1/12) = 1/2.
E[X2]=6∫01x3(1−x)dx=6∫01(x3−x4)dx=6[1/4−1/5]=6(1/20)=3/10\mathbb{E}[X^2] = 6\int_0^1 x^3(1-x)dx = 6\int_0^1 (x^3-x^4)dx = 6[1/4-1/5] = 6(1/20) = 3/10.
Var⁡(X)=3/10−(1/2)2=3/10−1/4=(6−5)/20=1/20\operatorname{Var}(X) = 3/10 - (1/2)^2 = 3/10 - 1/4 = (6-5)/20 = 1/20.

Document outline

Keep your place and jump directly to a heading.

Table of contents

No note selected

Open a chapter to see its outline, backlinks, and sources here.