This section is a workout in finding expectation and variance by conditioning. As before, if you are trying to find a probability, expectation, or variance, and you think, “If only I knew the value of this other random variable, I’d have the answer,” then that’s a sign that you should consider conditioning on that other random variable.
from IPython.display import YouTubeVideo
YouTubeVideo('-uYGQrQCXzM')
Let X have mean μX and SD σX. Let Y have mean μY and SD σY. Now let p be a number between 0 and 1, and define the random variable M as follows.
M={Xwith probability pYwith probability q=1−p
The distribution of M is called a mixture of the distributions of X and Y.
One way to express the definition of M compactly is to let IH be the indicator of heads in one toss of a p-coin; then
M=XIH+Y(1−IH)
To find the expectation of M we can use the expression above, but here we will condition on IH because we can continue with that method to find Var(M).
The distribution table of the random variable E(M∣IH) is
Value
μX
μY
Probability
p
q
The distribution table of the random variable Var(M∣IH) is
We have managed to come quite far into the course without deriving the variance of the geometric distribution. Let’s find it now by using the results about mixtures derived above.
Toss a coin that lands heads with probability p and stop when you see a head. The number of tosses X has the geometric (p) distribution on {1,2,…}. Let E(X)=μ and Var(X)=σ2. We will use conditioning to confirm that E(X)=1/p and also to find Var(X).
Now
X={1with probability p1+X∗with probability q=1−p
where X∗ is an independent copy of X. By the previous example,
Let N be a random variable with values 0,1,2,…, mean μN, and SD σN. Let X1,X2,… be i.i.d. with mean μX and SD σX, independent of N.
Define the random sumSN as
SN={0if N=0X1+X2+⋯+Xnif N=n>0
Then as we have seen before, E(SN∣N=n)=nμX for all n (including n=0). So
E(SN∣N)=NμX
and hence
E(SN)=E(NμX)=μXE(N)=μNμX
This is consistent with intuition: you expect to be adding μN i.i.d. random variables, each with mean μX. For the variance, intuition needs some guidance, which is provided by our variance decomposition formula.
First note that because we are adding i.i.d. random variables, Var(SN∣N=n)=nσX2 for all n (including n=0). That is,