…
…
Because you know all 1,200 students of a fictional dormitory, test the accuracy of an 80-student survey against the true value; write the right sentence for the director using repeated samples, a formula and a bootstrap interval, sample size, and the bias of a volunteer form.
The office of a student dormitory wants to know how many hours per week its students study on average, and runs a survey of 80 randomly chosen students. In the same term, an online form is opened with "fill it in if you want". In real life, you never have the answers of all the students in the dormitory; in this fictional dormitory, all 1,200 students are in the table. Thanks to this privilege, you can compare the result of every method with the true value: how far is the survey off, is the gap just chance, does the interval capture the true value, how many people do you need to ask, and why does the volunteer form mislead?
Data: dorm_population.csv (fictional sample data), each row is one student, 1,200 rows.
| Column | Description |
|---|---|
student_no | Student number (Y0001 … Y1200) |
block | Dormitory block: A, B, C or D |
year | Year of study: 1–4 |
study_hours | Weekly study time (hours) |
surveyed | 1 if chosen for the 80-student random survey, 0 if not |
volunteer | 1 if the student filled in the online volunteer form, 0 if not |
Product: the report sentences for the director, saying only as much as the data carries (step 8).
Lessons used: population, sample and volunteer response (3), sampling variability (25), standard error (26), the meaning of "95% confidence" and the bootstrap interval (30), the t interval (32).
Cells share one session; each step uses the variables of the one before. Simulations are seeded with np.random.default_rng(42), so when you run a cell again you see the same numbers.
What you'll do
dorm_population.csvDownload file
Reading file…
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
The dormitory office wants to know how many hours per week its students study on average. Normally it would only have the random survey of 80 students; in this project we also have all 1,200 students of the fictional dormitory. This lets us compare the survey with the true value to see how accurate it is (the trick from lesson 25).
First separate two numbers: the mean of the whole dormitory is a parameter, and the mean of the 80 people in the survey is a statistic. How many hours does the survey differ from the population mean?
This step's code cell is for members.Sign up free
The director asks: "The survey says 0.3 hours more. Did the person who ran the survey make a mistake?" The way to understand this is to imagine that many more surveys of 80 students were run in the same dormitory. Draw 10,000 samples of 80 from the population (with replacement, as in lesson 25, with default_rng(42)) and take the mean of each.
How much do the sample means move around the population mean? What share of the surveys deviate as much as ours or more?
This step's code cell is for members.Sign up free
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
In real life, we do not have all 1,200 students; we would have to answer the director with only the survey of 80. Build the t interval from lesson 32: the standard error comes from stats.sem and the critical value from stats.t.ppf.
Then use the privilege of this project: does the interval contain the true population mean?
This step's code cell is for members.Sign up free
Study times are skewed to the right: most students study between 7 and 16 hours, and a few study more than 30. Before trusting the formula, ask the same question with the bootstrap from lesson 30: from the 80 values of the survey, draw 10,000 samples of 80 with replacement (default_rng(42)) and take the middle 95% of their means.
Are the two methods close to each other?
This step's code cell is for members.Sign up free
The director asks: "Does 95% confidence mean there is a 95% chance that this interval is right?" You know from lesson 30: confidence belongs to the method, not to the interval. You can test this directly here, because we know the population mean.
Run 100 separate surveys of 80 students from the population (default_rng(42)). For each survey, build a t interval as in step 3 (t_crit is ready) and count how many of the intervals capture mu.
This step's code cell is for members.Sign up free
The director wants a more precise result next term. How much does the mean of a survey of 20, 80 and 320 students move around? For each size, draw 10,000 samples from the population, find the standard deviation of the means (the standard error from simulation), and compare it with the formula from lesson 26 (σ / √n). Make your prediction first:
The standard error of the 80-student survey is about 0.78 hours. If we raise the survey to 320 students (four times as many), about what will the standard error be?
Looking at the table, write the survey size that cuts the standard error in half compared with the 80-student survey as n_for_half.
This step's code cell is for members.Sign up free
In the same term, the dormitory office also opened an online form: "Fill it in if you want." The people who filled it in have 1 in the volunteer column. In the draft of the report, someone wrote: "259 people filled in the volunteer form, much bigger than the survey; let's use it."
259 people filled in the volunteer form, and the random survey has 80 people. Which mean do you think will be closer to the population mean (12.21 hours)?
Compute the volunteers' mean and the 95% t interval (stats.t.interval from lesson 32) and compare them with the population mean. Look at the share of students who study 20 hours or more in both groups.
This step's code cell is for members.Sign up free
Five sentences are suggested for the report to the director. Which ones say only as much as the data carries?
Write the letters of the correct sentences in the set correct_sentences.
This step's code cell is for members.Sign up free