Hi.
In this problem, we'll get more practice using
conditioning to help us calculate
expectations of variances.
We'll see that in this problem, which deals with
widgets and crates, it's actually similar in flavor to
an earlier problem that we did, involving breaking a
stick twice.
And you'll see that in this problem, we'll again use the
law of iterated expectations and the law of total variance
to help us calculate expectations of variances.
And again, we'll be taking the approach of attacking the
problem by splitting into the stages and building up from
the bottom up.
So in this problem, what we have is a crate, which
contains some number of boxes.
And we don't know how many boxes are.
It's random.
And it's given by some discrete random variable, n.
And in each box, there are some number of widgets.
And again, this is also random.
And in each box, say for Box I, there are xi number of
widgets in each one.
What we're really interested in in this problem is, how
many widgets are there total in this crate?
So in the crate, there are boxes, and in the boxes, there
are widgets.
How many widgets are there total within the crate?
And we'll call that a random variable, t.
And the problem gives us some information.
It tells us that the expectation of the number of
widgets in each box for all the boxes is the same.
It's 10.
And also, the expectation of the number of
boxes is also 10.
And furthermore, the variance of x of the number of widgets
and the number of boxes is all 16.
And lastly, an important fact is that all the xi's, so all
the widgets for each box, and the total number of boxes,
these random variables are all independent.
So to calculate t, t is just a sum of x1 through xn.
So x1 is the number of widgets in Box 1, z2 is the number of
widgets in Box 2, and all the way through Box n.
So what makes this difficult is that the
n is actually random.
We don't actually know how many boxes there are.
So we don't even know how many terms there are in the sum.
Well, let's take a slightly simpler problem.
Let's pretend that we actually know there
are exactly 12 boxes.
And in that case, the only thing that's random now is how
many widgets there are in each box.
And so let's call [? sum ?] a new random variable, s, the
sum of x1 through x12.
So this would tell us, this is the number of
widgets in 12 boxes.
All right.
And because each of these xi's are independent, and they have
the same expectation, just by linearity of expectations, we
know that the expectation of s is just 12 copies of the same
expectation of xi.
And similarly, because we also assume that all the xi's are
independent, the variance of s, we can just add the
variances of each of these terms.
So again, there are 12 copies of the variance of xi.
So we've done a simpler version of this problem, where
we've assumed we know what n is, that n is 12.
And we've seen that in this simpler case, it's pretty
simple to calculate what the expectation of the sum is.
So let's try to use that knowledge to help us calculate
the actual problem, where n is actually random.
So what we'll do is use the law of iterated expectations.
And so this is written in terms of x and y, but we can
very easily just substitute in for the random variables that
we care about.
Where in this case, what we see is that in order to build
things up, it would be helpful if we condition on something
that is useful.
And in this case, it's fairly clear that it would be helpful
if we condition on n, the number of boxes.
So if we knew how many boxes there were, then we can drop
down to the level of widgets within each box.
And then once we have that, we can build up and average over
the total number of boxes.
So what we should do is condition on n,
the number of boxes.
So what have we discovered through this
simpler exercise earlier?
Well, we've discovered that if we knew the number of boxes,
then the expectation of the total number of widgets is
just the number of boxes times the number of widgets in each
one, or the expectation of the number of widgets in each one.
So we can use that information to help us here.
Because now, this is basically the same scenario, except that
the number of boxes is now random.
Instead of being 12, it could be anything.
But if we just condition on the number of boxes being
equal to n, then we know that there are
exactly n copies of this.
But notice that n here is still random.
And so what we get is that the expectation is n times the
expectation of the number of widgets in each box, which we
know is 10.
So it's expectation of 10 times n or 10 times the
expectation of n, which gives us 100.
Because there are, on expectation, 10 boxes.
So this, again, makes intuitive sense.
Because we know that on average, there are 10 boxes.
And on average, each box has 10 widgets inside.
And so on average, we expect that
there will be 100 widgets.
And the key thing here is that we actually relied on this
independence.
So if the number of widgets in each box vary depending on--
or if the distribution of the number of widgets in each box
vary depending on how many boxes there were, then we
wouldn't be able to do it this simply.
OK, so that gives us the answer to the first part, the
expectation of the total number of widgets.
Now let's do the second part, which is the variance.
The variance, we'll again use this idea of conditioning and
splitting things up, and use the law of total variance.
So the variance of t is going to be equal to the expectation
of the conditional variance plus the variance of the
conditional expectation.
So what we have to do now is just to calculate what all of
these pieces are.
So let's start with this thing here,
the conditional variance.
So what is the conditional variance?
Well, again, let's go back to our simpler case.
We know that if we knew what n is, then the variance would
just be n times the variance of each xi.
So what does that tell us?
That tells us that, well, if we knew what n was, so
condition on n, the variance would just be n times the
variance of each xi.
So we've just taken this analogy and generalized it to
the case where we don't actually know what n is.
We just condition on n, and we still have a random variable.
So then from that, we know that the expectation now, to
get this first term, take the expectation of this
conditional variance, it's just the expectation of n and
the variance of xi, we're given that.
That's equal to 16.
So it's n times 16, which we know is 160, because the
expectation of n, we also know, is 10.
All right, let's do this second term now.
We need the variance of the conditional
expectation of t given n.
Well, what is the conditional expectation of t given n?
We've already kind of used that here.
And again, it's using the fact that if we knew what n was,
the expectation would just be n times the expectation of the
number of widgets in each box.
So it would be n times the expectation of each xi.
Now, to get the second term, we just take
the variance of this.
So the variance is the variance of n times the
expectation of each xi.
And the expectation of each xi is 10.
So it's n times 10.
And now remember, when you calculate variances,
[? if you ?] have a constant term inside, when you pull it
out, you have to square it.
So you get 100 times the variance of n.
And we know that the variance of n is also 16.
So this gives us 1600.
All right.
So now we've calculated both terms here.
The first term is equal to 160.
The second term is equal to 1600.
So to get the final answer, all we have to
do is add this up.
So we get that the final answer is equal to 1760.
And this is not as obvious as the expectation, where you
could have just kind of guessed that it
was equal to 100.
So again, this was just another example of using
conditioning and the laws of total variance and iterated
expectations in order to help you solve a problem.
And in this case, you could kind of see that there is a
hierarchy, where you start with widgets.
Widgets are contained in boxes, and then crates contain
some number of boxes.
And so it's easy to just condition and
do it level by level.
So you condition on the number of boxes.
If you know what the number of boxes are, then you can easily
calculate how many widgets there are, on average.
And then you average over the number of boxes to get the
final answer.
So I hope that was helpful.
And we'll see you next time.