Question 1.
In the following lines of code, we take two different samples from the earthquake table,
and calculate the mean of the magnitudes of these earthquakes. Are these samples representative
of the population of earthquakes in the original table (that is, the should we expect the mean to
be close to the population mean)?
Hint:
Consider the ordering of the
earthquakes
table.

Question 2.
Write code producing a sample that should represent the population of size 500
then take the mean of the magnitudes of the earthquakes in this sample.
Assign these to
representative_sample
and
representative_mean
respectively.
Hint:
In class, what sort of samples can properly represent the population?
[28]:
representative_sample
=
earthquakes
.
sample(
500
, with_replacement
=
False
)
representative_mean
=
np
.
mean(representative_sample
.
column(
'mag'
))
representative_mean
12

[28]:
4.812799999999999
[29]:
_
=
ok
.
grade(
'q4_2'
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
Question 3.
Suppose we want to figure out what the biggest magnitude earthquake was in 2017,
but we are tasked with doing this only with a sample of 500 from the earthquakes table.
To determine whether trying to find the biggest magnitude from a sample is a plausible idea, write
code that simulates the maximum of a random sample of size 500 from the
earthquakes
table 5000
times. Assign your array of maximums to
maximums
.

13

[32]:
_
=
ok
.
grade(
'q4_3'
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
Question 4.
We want to see if a random sample of size 500 is likely to help you determine the
largest magnitude earthquake in the population. To help determine this, find the magnitude of the
(actual) strongest earthquake in 2017.
[33]:
strongest_earthquake_magnitude
=
max
(earthquakes
.
column(
'mag'
))
strongest_earthquake_magnitude
[33]:
8.2
[34]:
_
=
ok
.
grade(
'q4_4'
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
14

---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed