[Math] Tower Property and Variance of a Random Variable (Lightbulb problem)

conditional-expectationexpectationprobability

Consider the following question:

Type i light bulbs function for a random amount of time having mean (mew)i and
standard deviation (sigma)i; where i = 1; 2. A light bulb randomly chosen from a bin of bulbs is a type 1 bulb with probability p and a type 2 bulb with probability 1-p. Let
X denote the lifetime of this bulb. Find E(X) and Var(X).

Here is a solution for reference:

Let $Y$ denote the type of the light bulb. We use the Tower property to get $$\mathbb E(X)=\Bbb E[\Bbb E(X|Y)]=\mu_1p+\mu_2(1-p).$$ We can either use law of total variance or calculate by conditioning: $$\eqalign{
\operatorname{Var}(X)&=\Bbb E(X^2)-(\Bbb E(X))^2\\&=\Bbb E[\Bbb E(X^2|Y)]-(\mu_1p+\mu_2(1-p))^2\\&=(\sigma_1^2+\mu_1^2)p+(\sigma_2^+\mu_2^2)(1-p)-(\mu_1p+\mu_2(1-p))^2\\&=(\mu_1-\mu_1)^2p(1-p)+\sigma_1^2p+\sigma^2_2(1-p).
}$$

I am having difficulty understanding the variance part of the solution for this question in my school probability assignment. May I please ask why the expectation of the expectation of X^2 conditioned on Y is (sigma(one)^2 + mean(one)^2)p + (sigma(two)^2 + mean(two)^2)(1-p)?

Thank you!

Best Answer

Calculating $E(E(X^2|Y))$ is completely analogous to calculating $(E(E(X|Y)).$ If $Z$ is a random variable of type i, we have $Var(Z) = E(Z^2) - E(Z)^2,$ and thus $E(Z^2) = Var(Z)+E(Z)^2 = \sigma_i^2+\mu_i^2.$ In order to get $E(E(X^2|Y)),$ we average over these calculations with probabilites $p$ for type 1 and $1-p$ for type 2. This gives $$ E(E(X^2|Y)) = p(\sigma_1^2+\mu_1^2)+(1-p)(\sigma_2^2+\mu_2^2), $$ as desired.

As I already said, it's completely analogous to the calculation of $E(E(X|Y)).$ If you understand the calculation of $E(E(X|Y)),$ you should also understand the calculation of $E(E(X^2|Y)).$