WEBVTT

00:00:00.970 --> 00:00:02.080
Hi.

00:00:02.080 --> 00:00:03.810
In this problem, we'll get
more practice using

00:00:03.810 --> 00:00:05.210
conditioning to help
us calculate

00:00:05.210 --> 00:00:07.090
expectations of variances.

00:00:07.090 --> 00:00:09.500
We'll see that in this problem,
which deals with

00:00:09.500 --> 00:00:12.170
widgets and crates, it's
actually similar in flavor to

00:00:12.170 --> 00:00:14.130
an earlier problem that we
did, involving breaking a

00:00:14.130 --> 00:00:15.616
stick twice.

00:00:15.616 --> 00:00:18.560
And you'll see that in this
problem, we'll again use the

00:00:18.560 --> 00:00:21.590
law of iterated expectations and
the law of total variance

00:00:21.590 --> 00:00:24.450
to help us calculate
expectations of variances.

00:00:24.450 --> 00:00:27.500
And again, we'll be taking the
approach of attacking the

00:00:27.500 --> 00:00:30.910
problem by splitting into the
stages and building up from

00:00:30.910 --> 00:00:32.840
the bottom up.

00:00:32.840 --> 00:00:36.370
So in this problem, what we
have is a crate, which

00:00:36.370 --> 00:00:38.220
contains some number of boxes.

00:00:38.220 --> 00:00:40.210
And we don't know how
many boxes are.

00:00:40.210 --> 00:00:40.940
It's random.

00:00:40.940 --> 00:00:45.200
And it's given by some discrete
random variable, n.

00:00:45.200 --> 00:00:48.990
And in each box, there are
some number of widgets.

00:00:48.990 --> 00:00:50.840
And again, this is
also random.

00:00:50.840 --> 00:00:56.240
And in each box, say for Box
I, there are xi number of

00:00:56.240 --> 00:00:58.750
widgets in each one.

00:00:58.750 --> 00:01:01.120
What we're really interested
in in this problem is, how

00:01:01.120 --> 00:01:03.800
many widgets are there
total in this crate?

00:01:03.800 --> 00:01:06.330
So in the crate, there are
boxes, and in the boxes, there

00:01:06.330 --> 00:01:06.820
are widgets.

00:01:06.820 --> 00:01:10.160
How many widgets are there
total within the crate?

00:01:10.160 --> 00:01:12.680
And we'll call that a
random variable, t.

00:01:12.680 --> 00:01:14.320
And the problem gives
us some information.

00:01:14.320 --> 00:01:18.200
It tells us that the expectation
of the number of

00:01:18.200 --> 00:01:21.930
widgets in each box for all
the boxes is the same.

00:01:21.930 --> 00:01:22.930
It's 10.

00:01:22.930 --> 00:01:25.650
And also, the expectation
of the number of

00:01:25.650 --> 00:01:27.760
boxes is also 10.

00:01:27.760 --> 00:01:30.790
And furthermore, the variance of
x of the number of widgets

00:01:30.790 --> 00:01:34.140
and the number of
boxes is all 16.

00:01:34.140 --> 00:01:38.070
And lastly, an important fact
is that all the xi's, so all

00:01:38.070 --> 00:01:41.730
the widgets for each box, and
the total number of boxes,

00:01:41.730 --> 00:01:45.590
these random variables
are all independent.

00:01:45.590 --> 00:01:54.520
So to calculate t, t is just
a sum of x1 through xn.

00:01:54.520 --> 00:01:57.800
So x1 is the number of widgets
in Box 1, z2 is the number of

00:01:57.800 --> 00:02:01.050
widgets in Box 2, and all
the way through Box n.

00:02:01.050 --> 00:02:03.660
So what makes this difficult
is that the

00:02:03.660 --> 00:02:05.060
n is actually random.

00:02:05.060 --> 00:02:07.200
We don't actually know how
many boxes there are.

00:02:07.200 --> 00:02:11.070
So we don't even know how many
terms there are in the sum.

00:02:11.070 --> 00:02:14.670
Well, let's take a slightly
simpler problem.

00:02:14.670 --> 00:02:16.290
Let's pretend that we
actually know there

00:02:16.290 --> 00:02:18.690
are exactly 12 boxes.

00:02:18.690 --> 00:02:23.180
And in that case, the only thing
that's random now is how

00:02:23.180 --> 00:02:25.280
many widgets there
are in each box.

00:02:25.280 --> 00:02:30.170
And so let's call [? sum ?] a
new random variable, s, the

00:02:30.170 --> 00:02:31.920
sum of x1 through x12.

00:02:31.920 --> 00:02:34.540
So this would tell us,
this is the number of

00:02:34.540 --> 00:02:37.910
widgets in 12 boxes.

00:02:37.910 --> 00:02:38.900
All right.

00:02:38.900 --> 00:02:42.280
And because each of these xi's
are independent, and they have

00:02:42.280 --> 00:02:45.260
the same expectation, just by
linearity of expectations, we

00:02:45.260 --> 00:02:51.740
know that the expectation of s
is just 12 copies of the same

00:02:51.740 --> 00:02:54.220
expectation of xi.

00:02:54.220 --> 00:02:57.500
And similarly, because we also
assume that all the xi's are

00:02:57.500 --> 00:03:01.100
independent, the variance of
s, we can just add the

00:03:01.100 --> 00:03:02.530
variances of each
of these terms.

00:03:02.530 --> 00:03:06.610
So again, there are 12 copies
of the variance of xi.

00:03:06.610 --> 00:03:09.010
So we've done a simpler version
of this problem, where

00:03:09.010 --> 00:03:12.910
we've assumed we know what
n is, that n is 12.

00:03:12.910 --> 00:03:16.000
And we've seen that in this
simpler case, it's pretty

00:03:16.000 --> 00:03:19.850
simple to calculate what the
expectation of the sum is.

00:03:19.850 --> 00:03:22.640
So let's try to use that
knowledge to help us calculate

00:03:22.640 --> 00:03:24.840
the actual problem, where
n is actually random.

00:03:27.420 --> 00:03:35.080
So what we'll do is use the law
of iterated expectations.

00:03:35.080 --> 00:03:38.220
And so this is written in terms
of x and y, but we can

00:03:38.220 --> 00:03:41.010
very easily just substitute in
for the random variables that

00:03:41.010 --> 00:03:41.610
we care about.

00:03:41.610 --> 00:03:46.690
Where in this case, what we see
is that in order to build

00:03:46.690 --> 00:03:52.510
things up, it would be helpful
if we condition on something

00:03:52.510 --> 00:03:54.360
that is useful.

00:03:54.360 --> 00:03:57.940
And in this case, it's fairly
clear that it would be helpful

00:03:57.940 --> 00:04:00.340
if we condition on n,
the number of boxes.

00:04:00.340 --> 00:04:02.960
So if we knew how many boxes
there were, then we can drop

00:04:02.960 --> 00:04:05.610
down to the level of widgets
within each box.

00:04:05.610 --> 00:04:08.410
And then once we have that, we
can build up and average over

00:04:08.410 --> 00:04:11.060
the total number of boxes.

00:04:11.060 --> 00:04:14.100
So what we should do
is condition on n,

00:04:14.100 --> 00:04:16.370
the number of boxes.

00:04:16.370 --> 00:04:19.820
So what have we discovered
through this

00:04:19.820 --> 00:04:21.269
simpler exercise earlier?

00:04:21.269 --> 00:04:25.310
Well, we've discovered that if
we knew the number of boxes,

00:04:25.310 --> 00:04:27.650
then the expectation of the
total number of widgets is

00:04:27.650 --> 00:04:30.870
just the number of boxes times
the number of widgets in each

00:04:30.870 --> 00:04:33.850
one, or the expectation of the
number of widgets in each one.

00:04:33.850 --> 00:04:39.680
So we can use that information
to help us here.

00:04:39.680 --> 00:04:45.590
Because now, this is basically
the same scenario, except that

00:04:45.590 --> 00:04:47.360
the number of boxes
is now random.

00:04:47.360 --> 00:04:50.010
Instead of being 12, it
could be anything.

00:04:50.010 --> 00:04:55.090
But if we just condition on
the number of boxes being

00:04:55.090 --> 00:04:57.040
equal to n, then we know
that there are

00:04:57.040 --> 00:04:59.550
exactly n copies of this.

00:04:59.550 --> 00:05:02.090
But notice that n here
is still random.

00:05:02.090 --> 00:05:08.370
And so what we get is that the
expectation is n times the

00:05:08.370 --> 00:05:10.940
expectation of the number of
widgets in each box, which we

00:05:10.940 --> 00:05:11.990
know is 10.

00:05:11.990 --> 00:05:17.830
So it's expectation of 10
times n or 10 times the

00:05:17.830 --> 00:05:22.210
expectation of n, which
gives us 100.

00:05:22.210 --> 00:05:27.040
Because there are, on
expectation, 10 boxes.

00:05:27.040 --> 00:05:28.850
So this, again, makes
intuitive sense.

00:05:28.850 --> 00:05:31.860
Because we know that on average,
there are 10 boxes.

00:05:31.860 --> 00:05:35.650
And on average, each box
has 10 widgets inside.

00:05:35.650 --> 00:05:37.330
And so on average,
we expect that

00:05:37.330 --> 00:05:39.260
there will be 100 widgets.

00:05:39.260 --> 00:05:42.120
And the key thing here is that
we actually relied on this

00:05:42.120 --> 00:05:42.920
independence.

00:05:42.920 --> 00:05:47.750
So if the number of widgets in
each box vary depending on--

00:05:47.750 --> 00:05:50.640
or if the distribution of the
number of widgets in each box

00:05:50.640 --> 00:05:53.170
vary depending on how many
boxes there were, then we

00:05:53.170 --> 00:05:54.790
wouldn't be able to
do it this simply.

00:05:57.850 --> 00:06:01.980
OK, so that gives us the answer
to the first part, the

00:06:01.980 --> 00:06:04.200
expectation of the total
number of widgets.

00:06:04.200 --> 00:06:08.820
Now let's do the second part,
which is the variance.

00:06:08.820 --> 00:06:14.850
The variance, we'll again use
this idea of conditioning and

00:06:14.850 --> 00:06:17.810
splitting things up, and use
the law of total variance.

00:06:17.810 --> 00:06:22.460
So the variance of t is going to
be equal to the expectation

00:06:22.460 --> 00:06:31.560
of the conditional variance
plus the variance of the

00:06:31.560 --> 00:06:32.810
conditional expectation.

00:06:35.100 --> 00:06:37.840
So what we have to do now is
just to calculate what all of

00:06:37.840 --> 00:06:39.380
these pieces are.

00:06:39.380 --> 00:06:41.810
So let's start with
this thing here,

00:06:41.810 --> 00:06:43.910
the conditional variance.

00:06:43.910 --> 00:06:45.510
So what is the conditional
variance?

00:06:48.640 --> 00:06:51.690
Well, again, let's go back
to our simpler case.

00:06:51.690 --> 00:06:55.530
We know that if we knew what n
is, then the variance would

00:06:55.530 --> 00:07:01.600
just be n times the variance
of each xi.

00:07:01.600 --> 00:07:02.860
So what does that tell us?

00:07:02.860 --> 00:07:06.240
That tells us that, well, if
we knew what n was, so

00:07:06.240 --> 00:07:11.180
condition on n, the variance
would just be n times the

00:07:11.180 --> 00:07:14.440
variance of each xi.

00:07:14.440 --> 00:07:18.350
So we've just taken this analogy
and generalized it to

00:07:18.350 --> 00:07:19.940
the case where we don't actually
know what n is.

00:07:19.940 --> 00:07:23.370
We just condition on n, and we
still have a random variable.

00:07:26.160 --> 00:07:30.340
So then from that, we know that
the expectation now, to

00:07:30.340 --> 00:07:32.840
get this first term, take
the expectation of this

00:07:32.840 --> 00:07:40.030
conditional variance, it's just
the expectation of n and

00:07:40.030 --> 00:07:42.120
the variance of xi,
we're given that.

00:07:42.120 --> 00:07:43.720
That's equal to 16.

00:07:43.720 --> 00:07:49.430
So it's n times 16, which we
know is 160, because the

00:07:49.430 --> 00:07:53.030
expectation of n, we
also know, is 10.

00:07:53.030 --> 00:07:56.130
All right, let's do this
second term now.

00:07:56.130 --> 00:07:57.680
We need the variance
of the conditional

00:07:57.680 --> 00:08:01.270
expectation of t given n.

00:08:01.270 --> 00:08:05.990
Well, what is the conditional
expectation of t given n?

00:08:05.990 --> 00:08:08.100
We've already kind of
used that here.

00:08:08.100 --> 00:08:12.600
And again, it's using the fact
that if we knew what n was,

00:08:12.600 --> 00:08:16.340
the expectation would just be n
times the expectation of the

00:08:16.340 --> 00:08:18.040
number of widgets in each box.

00:08:18.040 --> 00:08:20.800
So it would be n times the
expectation of each xi.

00:08:23.590 --> 00:08:25.490
Now, to get the second
term, we just take

00:08:25.490 --> 00:08:27.100
the variance of this.

00:08:27.100 --> 00:08:36.350
So the variance is the variance
of n times the

00:08:36.350 --> 00:08:37.909
expectation of each xi.

00:08:37.909 --> 00:08:41.330
And the expectation
of each xi is 10.

00:08:41.330 --> 00:08:43.679
So it's n times 10.

00:08:43.679 --> 00:08:46.540
And now remember, when you
calculate variances,

00:08:46.540 --> 00:08:48.810
[? if you ?] have a constant
term inside, when you pull it

00:08:48.810 --> 00:08:49.700
out, you have to square it.

00:08:49.700 --> 00:08:54.090
So you get 100 times
the variance of n.

00:08:54.090 --> 00:08:57.030
And we know that the variance
of n is also 16.

00:08:57.030 --> 00:09:01.340
So this gives us 1600.

00:09:01.340 --> 00:09:01.630
All right.

00:09:01.630 --> 00:09:04.140
So now we've calculated
both terms here.

00:09:04.140 --> 00:09:05.610
The first term is
equal to 160.

00:09:05.610 --> 00:09:07.570
The second term is
equal to 1600.

00:09:07.570 --> 00:09:09.290
So to get the final answer,
all we have to

00:09:09.290 --> 00:09:11.240
do is add this up.

00:09:11.240 --> 00:09:17.890
So we get that the final answer
is equal to 1760.

00:09:17.890 --> 00:09:21.480
And this is not as obvious as
the expectation, where you

00:09:21.480 --> 00:09:22.965
could have just kind
of guessed that it

00:09:22.965 --> 00:09:24.570
was equal to 100.

00:09:24.570 --> 00:09:28.320
So again, this was just another
example of using

00:09:28.320 --> 00:09:32.220
conditioning and the laws of
total variance and iterated

00:09:32.220 --> 00:09:34.360
expectations in order to help
you solve a problem.

00:09:34.360 --> 00:09:38.600
And in this case, you could kind
of see that there is a

00:09:38.600 --> 00:09:41.340
hierarchy, where you
start with widgets.

00:09:41.340 --> 00:09:43.920
Widgets are contained in boxes,
and then crates contain

00:09:43.920 --> 00:09:45.080
some number of boxes.

00:09:45.080 --> 00:09:49.260
And so it's easy to
just condition and

00:09:49.260 --> 00:09:50.140
do it level by level.

00:09:50.140 --> 00:09:52.210
So you condition on the
number of boxes.

00:09:52.210 --> 00:09:54.620
If you know what the number of
boxes are, then you can easily

00:09:54.620 --> 00:09:57.320
calculate how many widgets
there are, on average.

00:09:57.320 --> 00:09:59.300
And then you average over the
number of boxes to get the

00:09:59.300 --> 00:10:01.970
final answer.

00:10:01.970 --> 00:10:03.020
So I hope that was helpful.

00:10:03.020 --> 00:10:04.270
And we'll see you next time.