📘 Session 4.3 - Mean (Expected Value) and Variance

🔍 Definitions

Mean / Expected value of a continuous random variable \(X\) with PDF \(f(x)\):

\[ \mu = E[X] = \int_{-\infty}^{\infty} x\, f(x)\,dx \]

Variance measures spread around the mean:

\[ \operatorname{Var}(X) = E[(X-\mu)^2] = E[X^2] - \mu^2,\quad \text{where } E[X^2]=\int_{-\infty}^{\infty} x^2 f(x)\,dx \]

Think of \(\mu\) as the “balance point” of the PDF’s area; variance is the average squared distance from that balance point.

Example A: Uniform \(\text{Uniform}(a,b)\) interactive

PDF: \[ f(x)=\begin{cases} \dfrac{1}{b-a}, & a\le x\le b\\[4pt] 0,& \text{otherwise} \end{cases} \] Known results: \[ \mu=\dfrac{a+b}{2},\quad \operatorname{Var}(X)=\dfrac{(b-a)^2}{12},\quad \sigma=\dfrac{b-a}{\sqrt{12}} \]

Mean \(\mu\):
Var \(\sigma^2\):
Std dev \(\sigma\):
PDF with vertical lines at \(a\), \(b\), and the “balance point” \(\mu\) (which equals the median for Uniform).
Intuition: Riemann bars (\(x f(x)\Delta x\)) “pull” the balance point to \(\mu\).
Show steps (derivation with your \(a,b\))

Example B: Exponential \(\text{Exp}(\lambda)\) interactive

PDF \(f(x)=\lambda e^{-\lambda x}\) for \(x\ge0\). Known results: \[ \mu=\frac{1}{\lambda},\quad E[X^2]=\frac{2}{\lambda^2},\quad \operatorname{Var}(X)=\frac{1}{\lambda^2},\quad \sigma=\frac{1}{\lambda}. \]

Mean \(\mu\):
Var \(\sigma^2\):
Std dev \(\sigma\):
PDF with vertical lines at mean \(\mu=1/\lambda\) and median \(m=\ln 2/\lambda\).
Intuition: Bars approximate \(E[X]=\int x f(x)\,dx\) and track the balance point.
Show steps (derivation with your \(\lambda\))

✅ Takeaways

ℹ️ FYI — Reading the graphs: PDF vs CDF, \(f(x)\,dx\), and \(x\,f(x)\,dx\)

1) What does \(f(x)\,dx\) mean?

\(f(x)\,dx\) is an approximate probability that \(X\) falls in the tiny interval \([x, x+dx]\).

Geometrically, it’s a tiny area under the PDF: height \(=f(x)\), width \(=dx\).

Probability over any interval equals the area under the PDF:

\[ P(a\lt X\le b)=\int_{a}^{b} f(x)\,dx. \]

Note: This is about the PDF, not the CDF. We don’t take “area under the CDF.”

2) What does \(x\,f(x)\,dx\) mean?

\(x\,f(x)\,dx\) is not a probability. It’s a tiny contribution to the mean (expected value):

\[ E[X] \;=\; \int_{-\infty}^{\infty} x\,f(x)\,dx \;\approx\; \sum x_i\,f(x_i)\,\Delta x . \]

Think of \(f(x)\,dx\) as a small “weight” at position \(x\). Each piece creates a little torque \(x\times \text{(weight)}\). The point where left/right torques cancel is the balance point \( \mu \) (the mean).

This is exactly what your “Riemann bars \((x\,f(x)\,\Delta x)\)” chart is showing.

3) CDF facts you’ll use a lot

\[ F(k)=P(X\le k)=\int_{-\infty}^{k} f(u)\,du \]

\[ P(a\lt X\le b)=\int_{a}^{b} f(x)\,dx \;=\; F(b)-F(a) \]

  • \(F\) goes from 0 to 1 and never decreases.
  • \(f\) is the derivative of \(F\): \(f(x)=\dfrac{d}{dx}F(x)\).
4) Mean vs Median (don’t mix them up)

Mean \(\mu\): balance point (center of mass). It satisfies \[ \int_{-\infty}^{\mu}(\mu-x)f(x)\,dx = \int_{\mu}^{\infty}(x-\mu)f(x)\,dx . \]

Median \(m\): splits the area in half, so \(F(m)=0.5\).

  • Symmetric distributions (e.g., Uniform \([a,b]\)) → mean \(=\) median.
  • Right-skewed (e.g., Exponential) → mean \(>\) median (pulled toward the long right tail).

Example (Exponential \(\lambda=0.04\)): mean \(=1/\lambda=25\), median \(=\ln 2/\lambda\approx17.33\). At \(x=25\), left area is \(F(25)\approx0.632\) (not 0.5) — but torques balance there.

5) One tiny numeric check (Uniform \([0,2]\))

\(f(x)=\tfrac12\). A small bin width \(dx=0.1\) at \(x=1.75\):

  • \(f(x)\,dx \approx \tfrac12\cdot 0.1 = 0.05\) (probability in that bin).
  • \(x\,f(x)\,dx \approx 1.75\cdot \tfrac12\cdot 0.1 = 0.0875\) (that bin’s contribution to the mean).

Summing all such \(x\,f(x)\,dx\) across \([0,2]\) gives \(E[X]=1\) (the midpoint).