In [3]:
Lab 7: Resampling and the Bootstrap
The British Royal Air Force wanted to know how many warplanes the Germans had (some number N , which is
a parameter), and they needed to estimate that quantity knowing only
...
In [3]:
Lab 7: Resampling and the Bootstrap
The British Royal Air Force wanted to know how many warplanes the Germans had (some number N , which is
a parameter), and they needed to estimate that quantity knowing only a random sample of the planes' serial
numbers (from 1 to N ). We know that the German's warplanes are labeled consecutively from 1 to N , so N
would be the total number of warplanes they have.
We normally investigate the random variation among our estimates by simulating a sampling procedure from
the population many times and computing estimates from each sample that we generate. In real life, if the RAF
had known what the population looked like, they would have known N and would not have had any reason to
think about random sampling. However, they didn't know what the population looked like, so they couldn't
have run the simulations that we normally do.
Simulating a sampling procedure many times was a useful exercise in understanding random variation for an
estimate, but it's not as useful as a tool for practical data analysis.
Let's flip that sampling idea on its head to make it practical. Given just a random sample of serial numbers,
we'll estimate N , and then we'll use simulation to find out how accurate our estimate probably is, without ever
looking at the whole population. This is an example of statistical inference.
As usual, run the cell below to prepare the lab and the automatic tests.
=====================================================================
Assignment: Resampling and the Bootstrap
OK, version v1.12.5
=====================================================================
# Initialize OK
from client.api.notebook import Notebook
ok = Notebook('lab07.ok')In [4]:
1. Preliminaries
We (the RAF in World War II) want to know the number of warplanes fielded by the Germans. That number is
N . The warplanes have serial numbers from 1 to N , so N is also equal to the largest serial number on any of
the warplanes.
We only see a small number of serial numbers (assumed to be a random sample with replacement from among
all the serial numbers), so we have to use estimation.
Question 1.1
Is N a population parameter or a statistic? If we use our random sample to compute a number that is an
estimate of N , is that a population parameter or a statistic?
=====================================================================
Assignment: Resampling and the Bootstrap
OK, version v1.12.5
=====================================================================
Saving notebook... Saved 'lab07.ipynb'.
Submit... 100% complete
Submission successful for user:
[email protected]
URL: https://okpy.org/cal/data8/sp19/lab07/submissions/mO86Qr
(https://okpy.org/cal/data8/sp19/lab07/submissions/mO86Qr)
# Run this cell to set up the notebook, but please don't change it.
# These lines import the Numpy and Datascience modules.
import numpy as np
from datascience import *
# These lines do some fancy plotting magic.
import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
import warnings
warnings.simplefilter('ignore', FutureWarning)
# These lines load the tests.
from client.api.notebook import Notebook
ok = Notebook('lab07.ok')
_ = ok.submit()N is a population parameter, and an estimate is a statistic.
Check your answer with a neighbor or a TA.
To make the situation realistic, we're going to hide the true number of warplanes from you. You'll have access
only to this random sample
[Show More]