2025-11-12
Define and calculate the expected value for a function of discrete and continuous RVs
Define and calculate variance for a single random variable
Define and calculate variance for multiple random variables
Example 1
Let \(g\) be a function and let \(g(x) = ax+b\), for real-valued constants \(a\) and \(b\). What is \(\mathbb{E}[g(X)]\)?
Expected value of function of discrete RV
For any function \(g\) and discrete RV \(X\), the expected value of \(g(X)\) is \[\mathbb{E}[g(X)] = \sum_{\{all\ x\}}\ g(x) p_X(x)\]
Expected value of function of continuous RV
For any function \(g\) and continuous RV \(X\), the expected value of \(g(X)\) is \[\mathbb{E}[g(X)] = \displaystyle\int_{-\infty}^\infty g(x)f_X(x) dx\]
Example 2
Suppose you draw 2 cards from a standard deck of cards with replacement. Let \(X\) be the number of hearts you draw.
Recall Binomial RV with \(n=2\):
\[p_X(x) = {2 \choose x}p^x(1-p)^{2-x} \text{ for } x = 0, 1, 2\]
Example 2
Suppose you draw 2 cards from a standard deck of cards with replacement. Let \(X\) be the number of hearts you draw.
Recall Binomial RV with \(n=2\):
\[p_X(x) = {2 \choose x}p^x(1-p)^{2-x} \text{ for } x = 0, 1, 2\]
Definition: Variance of RV
The variance of a RV \(X\), with (finite) expected value \(\mu_X=\mathbb{E}[X]\) is \[\sigma_X^2=Var(X)=\mathbb{E}[(X-\mu_X)^2] = \mathbb{E}[(X-\mathbb{E}[X])^2]\]
Definition: Standard deviation of RV
The standard deviation of a RV \(X\) is \[\sigma_X = SD(X) = \sqrt{\sigma_X^2}=\sqrt{Var(X)}.\]
How do we calculate the variance of a discrete RV?
For discrete RVs:
\[ \begin{align} Var(X) & = \\ & = \sum_{\{all\ x\}}(x-\mu_x)^2 p_{X}(x) \\ & = \mathbb{E}[(X-\mu_X)^2] \\ & = \mathbb{E}[(X-\mathbb{E}[X])^2] \\ &= \mathbb{E}[X^2]-(\mathbb{E}[X])^2 \end{align} \]
How do we calculate the variance of a continuous RV?
For continuous RVs:
\[ \begin{align} Var(X) & = \displaystyle\int_{-\infty}^\infty (x-\mu_X)^2f_X(x) dx \\ & = \mathbb{E}[(X-\mu_X)^2] \\ & = \mathbb{E}[(X-\mathbb{E}[X])^2] \\ &= \mathbb{E}[X^2]-(\mathbb{E}[X])^2 \end{align} \]
Lemma 6: “Computation formula” for Variance
The variance of a RV \(X\), can be computed as \[\begin{align} \sigma_X^2 & =Var(X) \\ & = \mathbb{E}[X^2]-\mu_X^2 \\ & = \mathbb{E}[X^2] - (\mathbb{E}[X])^2 \end{align}\]
Example 2
Let \(f_X(x)= \frac{1}{b-a}\), for \(a \leq x \leq b\). Find \(Var[X]\).
In the homework:
Example 3
Let \(f_X(x)= \lambda e^{-\lambda x}\), for \(x > 0\) and \(\lambda> 0\). Find \(Var[X]\).
Define and calculate the expected value for a function of discrete and continuous RVs
Define and calculate variance for a single random variable
Lemma 7
For a RV \(X\) and constants \(a\) and \(b\), \[Var(aX+b) = a^2Var(X).\]
Proof will be exercise in homework. It’s fun! In a mathy kinda way.
Theorem 8
For independent RV’s \(X\) and \(Y\), and functions \(g\) and \(h\), \[\mathbb{E}[g(X)h(Y)] = \mathbb{E}[g(X)]\mathbb{E}[h(Y)].\]
Corollary 1
For independent RV’s \(X\) and \(Y\), \[\mathbb{E}[XY] = \mathbb{E}[X]\mathbb{E}[Y].\]
Theorem 9: Variance of sum of independent discrete RV’s
For independent discrete RV’s \(X_i\) and constants \(a_i\), \(i=1,2,\dots, n\), \[Var\Bigg(\sum_{i=1}^n a_iX_i\Bigg) = \sum_{i=1}^n a_i^2Var(X_i).\]
Simpler version:
\[Var(a_1 X + a_2 Y) = Var(a_1X) + Var(a_2 Y) = a_1^2 Var(X) + a_2^2 Var(Y)\]
Corollary 2
For independent discrete RV’s \(X_i\), \(i=1,2,\dots, n\), \[Var\Bigg(\sum_{i=1}^n X_i\Bigg) = \sum_{i=1}^n Var(X_i).\]
Corollary 3
For independent identically distributed (i.i.d.) discrete RV’s \(X_i\), \(i=1,2,\dots, n\), \[Var\Bigg(\sum_{i=1}^n X_i\Bigg) = n Var(X_1).\]
Example 3.2
The ghost is trick-or-treating at a different house now. In this case it is known that the bag of candy has 10 chocolates, 20 lollipops, and 30 laffy taffies. The ghost grabs a handful of five pieces of candy. What is the variance for the number of chocolates the ghost takes? Let’s solve this for the cases with replacement.
Recall probability with replacement:
\[ p_X(x) = {n \choose k}p^k(1-p)^{n-k} \]
Example 4
A tour group is planning a visit to the city of Minneapolis and needs to book 30 hotel rooms. The average price of a room is $200 with standard deviation $10. In addition, there is a 10% tourism tax for each room. What is the standard deviation of the cost for the 30 hotel rooms? Assume rooms are independent.
Problem to do at home if we don’t have enough time.
Example 4
A machine manufactures cubes with a side length that varies uniformly from 1 to 2 inches. Assume the sides of the base and height are equal. The cost to make a cube is 10 ¢ per cubic inch, and 5 ¢ cents for the general cost per cube. Find the mean and standard deviation of the cost to make 10 cubes.
Lesson 14 Slides