Lecture 12

Expected Values and Variance


Grace Tompkins

Last modified — 21 Jun 2026

Final Exam Information

Warning

Our final exam is scheduled for June 22nd, 2026 at 8:30am. Please find the room location on Workday.

The exam is 2.5 hours, with the exact same rules as the midterm.

Learning Outcomes

By the end of this lecture, students are anticipated to be able to:

  • Define and calculate expected values, variance, and standard deviation from discrete and continuous distributions

1 Expected Values

Expected Value of Random Variables

The expected value of a random variable \(g(X)\) is defined by

\[ \mathbb{E}[g(X)] = \begin{cases} \displaystyle\sum_{x} g(x) p_X(x) & \text{if $X$ is discrete}\\ \\ \displaystyle\int_{-\infty}^\infty g(x) f_X(x) \mathsf{d}x & \text{if $X$ is absolutely continuous} \end{cases} \]

provided that the sum or integral exists.

  • The sum in the discrete case is over all \(x\) such that \(p_X(x) > 0\) (countable).
  • The sum/integral exists when \(\mathbb{E}[|g(X)|] < \infty\). Otherwise, we say that \(\mathbb{E}[g(X)]\) does not exist.
  • Note that you do not need to know the distribution/PMF/PDF/CDF of \(g(X)\) to compute \(\mathbb{E}[g(X)]\), only the distribution of \(X\) itself.

Expected Value of a Random Variable

Let \(X\) be the value of the face of a die when rolled. What is the expected value of \(X\)?

Expected Value of a Random Variable

Let \(X \sim {\mathrm{Binom}}(n, \theta)\). What is \(\mathbb{E}[X]\)? Hint: we can use “kernel matching” and use the fact that \(x\binom{n}{x} = n\binom{n-1}{x-1}\).

Expected Value of a Random Variable

Expected Value of a Random Variable

Suppose\(X \sim \textrm{Gamma}(\alpha, \lambda )\). What is \(\mathbb{E}[X]\)? Hint: kernel matching!

Expected Value of a Random Variable

Expected Value of a Random Variable

Let \(X \sim {\mathrm{Gam}}(\alpha, \lambda)\) where \(\alpha>0\) and \(\lambda > 0\). Recall that the PDF of a RV \(Y\sim{\mathrm{Gam}}(\theta, \beta)\) is given by \[f_X(x) = \frac{\beta^\theta}{\Gamma(\theta)} x^{\theta - 1} e^{-\beta x} I_{(0,\infty)}(x).\]

Let \(t < \lambda\). Find \(\mathbb{E}[\exp(tX)]\).

Expected Value of a Random Variable

Important Properties

(Where the expected value exists.)

Linearity
for any \(a, b, c \in {\mathbb{R}}\), any functions \(g\) and \(h\), and any random variables \(X\) and \(Y\). \[\mathbb{E}[a g(X) + b h(Y) + c] = a \mathbb{E}[g(X)] + b \mathbb{E}[h(Y)] + c\]
Boundedness
If \(a< g(x) < b\) for all \(x\) in the support of \(X\), then \(a < \mathbb{E}[g(X)] < b.\)


Monotonicity
If \(g(x) \le h(x)\) for all \(x\) in the support of \(X\), then \(\mathbb{E}[g(X)] \le \mathbb{E}[h(X)].\)


Independence
If \(X\) and \(Y\) are independent, then \[\mathbb{E}[g(X) h(Y)] = \mathbb{E}[g(X)] \mathbb{E}[h(Y)].\]

For the last property, the converse is false.

Expected Value of A Function of Two Random Variables

Let \(X\sim U(0,\theta)\) and \(Y\sim{\mathrm{Exp}}(1)\) be independent.

Find \(\mathbb{E}\left[\frac{1}{2}(X + Y)^2\right]\).

Expected Value of A Function of Two Random Variables

Scalar-valued Functions of Multiple Random Variables

Let \(g : {\mathbb{R}}^2 \to {\mathbb{R}}\) be a function.

If \(X\) and \(Y\) are both discrete random variables, then \[\begin{aligned} \mathbb{E}[g(X, Y)] &= \sum_{x} \sum_{y} g(x, y) p_{X,Y}(x, y). \end{aligned}\] If \(X\) and \(Y\) are jointly absolutely continuous random variables, then \[\begin{aligned} \mathbb{E}[g(X, Y)] &= \int_{-\infty}^\infty \int_{-\infty}^\infty g(x, y) f_{X,Y}(x, y) \mathsf{d}x \mathsf{d}y. \end{aligned}\]

Product of Expectations

  • If \(X\) and \(Y\) are independent, then \(\mathbb{E}[g(X)h(Y)] = \mathbb{E}[g(X)]\mathbb{E}[h(Y)]\).

Suppose that \(X\) and \(Y\) are jointly absolutely continuous random variables with joint PDF \(f_{X,Y}(x, y)\). Note that \(\mathbb{E}[g(X)h(Y)]\) is a scalar-valued function of \(X\) and \(Y\).

\[\begin{aligned} \mathbb{E}[g(X)h(Y)] &= \int_{-\infty}^\infty \int_{-\infty} ^\infty g(x) h(y) f_{X,Y}(x, y) \mathsf{d}x \mathsf{d}y \\ &= \int_{-\infty}^\infty \int_{-\infty}^\infty g(x) h(y) f_X(x) f_Y(y) \mathsf{d}x\mathsf{d}y && \text{$X$ and $Y$ are independent} \\ &= \int_{-\infty}^\infty g(x) f_X(x) \mathsf{d}x \int_{-\infty}^\infty h(y) f_Y(y) \mathsf{d}y \\ &= \mathbb{E}[g(X)] \mathbb{E}[h(Y)]. \end{aligned}\]

Expectations from a Joint Distribution

Let \(X\) and \(Y\) have joint PDF \[f_{X,Y}(x,y) = 8xyI_{\{0 < x < y < 1\}}(x,y).\]

  1. Calculate \(\mathbb{E}[X]\).
  2. Calculate \(\mathbb{E}[Y]\).
  3. Calculate \(\mathbb{E}[XY]\).

Expectations from a Joint Distribution

Expectations from a Joint Distribution

2 Variance

Variance

The variance of a random variable \(X\) is defined by \[ \begin{aligned} \sigma^2_X &= \operatorname{Var}(X) \\ &= \mathbb{E}[(X - \mathbb{E}[X])^2] &\text{(this is the "definition"...)}\\ &= \mathbb{E}[X^2] - \mathbb{E}[X]^2 & \text{(... but this version is often easier for calculations)} \end{aligned} \]

  • Careful here: \(\mathbb{E}[X]\) is a number, not a random variable.
  • The variance is a measure of the spread of the distribution of \(X\) around its mean \(\mathbb{E}[X]\).
  • Note that \(g(X) = (X - \mathbb{E}[X])^2\) is a function of \(X\), so we can compute \(\operatorname{Var}(X)\) using the definition of expected value.

Variance

  • The “units” of \(\operatorname{Var}(X)\) are the square of the units of \(X\), so sometimes we want to look at the spread of the distribution in the original units.

The standard deviation of a random variable \(X\) is defined by \[\sigma_X = \sqrt{\operatorname{Var}(X)}.\]

Properties of variance

(Where the variance exists.)

Scaling
For any \(a \in {\mathbb{R}}\), \(\operatorname{Var}(aX) = a^2 \operatorname{Var}(X)\).
Shift invariance
For any \(a \in {\mathbb{R}}\), \(\operatorname{Var}(X + a) = \operatorname{Var}(X)\).
Non-negativity
\(\operatorname{Var}(X) \ge 0\).
Relationship between \(\operatorname{Var}(X)\) and \(\mathbb{E}(X^2)\)
\[\begin{aligned} \operatorname{Var}(X) &= \mathbb{E}[(X - \mathbb{E}[X])^2] \\ &= \mathbb{E}[X^2 - 2X\mathbb{E}[X] + \mathbb{E}[X]^2] \\ &= \mathbb{E}[X^2] - 2\mathbb{E}[X]\mathbb{E}[X] + \mathbb{E}[X]^2 \\ &= \mathbb{E}[X^2] - \mathbb{E}[X]^2.\\ \Longrightarrow \operatorname{Var}(X) &\le \mathbb{E}[X^2]. \end{aligned}\]

Variance

Let’s do the following example together.

Let \(X \sim {\mathrm{Unif}}(0,1)\). Find \(\operatorname{Var}(X)\).

Recall if \(X \sim Unif(L,R)\), then \[f_X(x; L, R) = \frac{1}{R-L}I_{[L,R]}(x)\]

Variance

Variance

Variance

Let \(X \sim {\mathrm{Exp}}(\lambda)\). Find \(\operatorname{Var}(X)\).

Hints: remember that \(\mathbb{E}[X] = 1/\lambda\) and that \(\Gamma(z) = (z-1)!\) for integer \(z > 1\).

Variance

Variance

To Do

  • Work on Assignment 3, due Wednesday June 10, 11:59pm on Gradescope.
  • Read Chapter 3.3 and 3.4 before next class.