False
);
# Min sample size is 0, max is 400
# The graph will refresh a few times when you drag the slider around
interactive(children=(IntSlider(value=200, description=
'
x
'
, max=400), Output()), _dom_classes=(
You can see that even the means of samples of 10 items follow a roughly bell-shaped distribu-
tion. A sample of 50 items looks quite bell-shaped.
9

</div>
Question 2:
In the plot for a sample size of 10, why are the bars spaced at intervals of
.1, with gaps in between?

10

</div> Now we will test the second claim of the CLT: That the SD of the sample mean is the
SD of the original distribution, divided by the square root of the sample size.
We have imported the flight delay data and computed its standard deviation for you.
In [15]:
united
=
Table
.
read_table(
'
united_summer2015.csv
'
)
united_std
=
np
.
std(united
.
column(
'
Delay
'
))
united_std
Out[15]:
39.480199851609314
11

</div>
Question 3:
Write a function called
empirical_sample_mean_sd
that takes a sample
size
n
as its argument. The function should simulate 500 samples with replacement of size
n
from
the flight delays dataset, and it should return the standard deviation of the
means of those 500
samples
.
Hint:
This function will be similar to the
sample_size_n
function you wrote earlier.
In [16]:
united
Out[16]:
Date
| Flight Number | Destination | Delay
6/1/15 | 73
| HNL
| 257
6/1/15 | 217
| EWR
| 28
6/1/15 | 237
| STL
| -3
6/1/15 | 250
| SAN
| 0
6/1/15 | 267
| PHL
| 64
6/1/15 | 273
| SEA
| -6
6/1/15 | 278
| SEA
| -8
6/1/15 | 292
| EWR
| 12
6/1/15 | 300
| HNL
| 20
6/1/15 | 317
| IND
| -10
... (13815 rows omitted)
In [17]:
def
empirical_sample_mean_sd
(n):
sample_means
=
make_array()
for
i
in
np
.
arange(
500
):
sample
=
united
.
sample(n)
.
column(
"Delay"
)
sample_mean
=
np
.
mean(sample)
sample_means
=
np
.
append(sample_means, sample_mean)
return
np
.
std(sample_means)
empirical_sample_mean_sd(
10
)
Out[17]:
12.502203805729613
In [18]:
_
=
ok
.
grade(
'
q2_3
'
)
_
=
ok
.
backup()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
<IPython.core.display.Javascript object>
12

<IPython.core.display.Javascript object>
Saving notebook... Saved
'
hw09.ipynb
'
.
Backup... 100% complete
Backup successful for user: [email protected]
URL:
NOTE: this is only a backup. To submit your assignment, use:
python3 ok --submit
Question 4:
Now, write a function called
predict_sample_mean_sd
to find the predicted value
of the standard deviation of means according to the relationship between the standard deviation
of the sample mean and sample size that is discussed
here
in the textbook. It takes a sample size
n
(a number) as its argument. It returns the predicted value of the standard deviation of the mean
delay time for samples of size
n
from the flight delays (represented in the table
united
).
In [19]:
def
predict_sample_mean_sd
(n):
return
united_std
/
(n)
**.5
predict_sample_mean_sd(
10
)
Out[19]:
12.484735400972708
In [20]:
_
=
ok
.
grade(
'
q2_4
'
)
_
=
ok
.
backup()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Saving notebook... Saved
'
hw09.ipynb
'
.