We now continue the study of the sum of a random number of
independent random variables.
We already figured out what is the expected value of this
sum, and we found a fairly simple answer.
When it comes to the variance, however, it's pretty hard to
guess what the answer will be, and it turns out that the
answer is not as simple.
So this is what we will try to calculate now.
The way to proceed will be to use the law of total variance,
which effectively breaks down the problem by conditioning on
the value of the random variable capital
N. So let us start.
We have already figured out that if I tell you the value
of capital N, then the expected value of the random
variable Y is just this number, capital N, the number
of stores you are visiting, times how much you are
spending in each one of the stores.
Using this information, we can now calculate this term, the
variance of the conditional expectation.
What is it?
It's the variance of capital N times the expected value of X.
Now, the expected value of X is a constant, and when we
multiply a random variable with a constant, what that
does to the variance is it multiplies the variance with
the square of that constant.
And this gives us this term in the law of total variance.
Let us now work towards the second term.
If I tell you the number of stores, then the random
variable Y is just a sum of a given
number of random variables.
And as we discussed before, the conditioning that we have
here may be eliminated because these random variables are now
independent of this random variable, capital N. Their
distribution does not change based on this information, and
so we obtain the unconditional variance.
Now, the unconditional variance of a sum of n random
variables is just n times the variance of each one of them,
which we denote with this notation.
Now, let us take this equality, which is an equality
between numbers, and it's true for any particular choice of
little n, and turn it into an equality
between random variables.
This is the random variable that takes this specific value
when capital N is equal to little n.
So this is a random variable that takes this specific value
when capital N is equal to little n, but this is also the
same as this random variable, n times the variance of X,
because this random variable takes this particular
numerical value when capital N is equal to little n.
Now that we have an expression for the conditional variance
as a random variable, we can take the next step and
calculate the expected value of the conditional variance.
The expected value of the conditional variance is simply
the expected value of this expression that we
calculated up here.
And now the variance of X is a constant and can be pulled
outside the expectation, which leaves us with
this expression here.
Now that we have calculated both terms that go into the
law of total variance, we can add these two terms.
We have one contribution from here, this is this term, and
another contribution from here, which is this term.
What this expression tells us is that the variance of the
total amount that you spend, which is a certain measure of
the amount of randomness in how much you are spending
overall, this amount of randomness
is due to two causes.
One cause is the randomness that there is in how much
money you spend in any given store, and that's captured by
the variance of X. It's the variance of the distribution
of the amount of money that you spend in a typical store.
But there is another source of randomness, and that source of
randomness comes from the fact that the number of stores
itself is random, and this gives us this contribution to
the variance of Y.
By taking into account these two sources of randomness, we
can figure out the overall variance of the random
variable Y. As you can see, this is a formula that would
be hard to guess by just reasoning intuitively.
And so it's a demonstration of the power of the law of the
total variance.