L25 Four Ways to Draw

DATA SCIENCE · CYCLE 2 · L25 · TEXTBOOK CHAPTER

Four Ways to Draw

A random sample lets chance pick, so no one’s lean gets in. There are four ways to do it, and each fits a different situation. All four are fair. What differs is how far one sample can miss.

After this chapter, you can

For your project: a SAMPLE tab of 300 random rows if your CLEAN is big, and one line on ABOUT that says whether your file is a sample. The checkpoint is at the end.

Why It Matters

In 1948 the polls said Thomas Dewey would beat President Harry Truman. The Gallup Poll’s final estimate had Dewey at 49.5% and Truman at 44.5%.

Truman won, 49.5% to 45.1%. Gallup’s forecast for Truman missed by 44.5 − 49.5 = −5.0 points, and it named the wrong winner.

The polls used quota samples. Each interviewer had counts to fill: so many men, so many women, so many young and old. Inside those counts, the interviewer chose whom to ask. A review after the election told pollsters to stop using quotas and to use samples drawn by chance “at all levels of respondent selection”. The pollsters had also stopped asking two weeks before Election Day, sure nothing would change. They fixed both.

The Idea

Let chance pick

A random sample lets chance pick, so no one’s lean gets in. There are four ways, and each fits a different situation.

WayHow, for 10 of 100Fits when
simple random sampleshuffle the list; take the first 10you have a list of everyone
systematic samplea random start from 1 to 10, then every 10tha list or a line with no pattern
stratified sampleat random within each group, in proportionthe groups differ, and each must be in
cluster samplewhole groups at random, everyone in themgroups are alike, and a few are cheap to reach
quota samplea set count from each group; a person chooses whonever: the chooser’s lean gets in

All four are fair: over many samples their misses land on both sides of 0. They differ in how far one sample can miss. A sample’s bias is its mean minus the true mean, as in L24.

Try It: Draw 10, Four Ways

Here is the class’s school of 100, the same as your SCHOOL tab: a row for each homeroom of 10, each student’s id (small) and hours of sleep on a school night. The darker the shading, the higher the grade. Each homeroom is one grade. Press a way to draw 10 students, and watch its dot land on that way’s row. Then press 20 of each. Which row stays inside the shaded band, within 0.3 of 0? Which spreads widest?

Worked Examples

Example 1 · Every kth on a list. A running club has 480 members on a list, ids 1 to 480 in A2 to A481. The coach wants a systematic sample of 24.

Create a strategy

Find the step: the list size divided by the sample size. Draw a random start from 1 to the step, freeze it, then take every step-th id.

Apply the idea

The step is 480 ÷ 24 = 20. =RANDBETWEEN(1,20), frozen, gave 13. The ids are 13, 33, 53, and on to 13 + 23 × 20 = 473. In Sheets, =FILTER(A2:A481,MOD(A2:A481-13,20)=0) gives all 24.

Reflect and check

24 ids, the first 13 and the last 473. Every member had the same chance: 1 in 20. Check the list has no pattern every 20. If it listed teams of 20 with each captain first, a start of 1 would pick only captains.

Example 2 · In proportion. A hospital has 300 nurses: 150 on the day shift, 90 on the evening shift and 60 on the night shift. Night nurses sleep very differently. A survey of 20 asks about sleep.

Create a strategy

The shifts differ, and each must be in, so stratify by shift. Each shift gets its share of the 20: the shift’s size ÷ 300 × 20.

Apply the idea

Day: 150 ÷ 300 × 20 = 10. Evening: 90 ÷ 300 × 20 = 6. Night: 60 ÷ 300 × 20 = 4. Then 10 at random from the day nurses, 6 from the evening and 4 from the night.

Reflect and check

10 + 6 + 4 = 20. A stratified sample always holds 4 night nurses, the hospital’s own share. A simple random 20 holds exactly 4 only about 23 times in 100, and 1 or none about 6 times in 100. Those samples would miss the night shift’s sleep.

Example 3 · One cluster. A district has 6 schools of 500 students each. Their mean hours of screen time on a school night are 3.2, 4.0, 2.6, 5.1, 3.5 and 4.4. A cluster sample picks one school at random and asks everyone in it.

Create a strategy

The schools are the same size, so the district’s true mean is the mean of the six. Then find the bias if school 4 is picked.

Apply the idea

3.2 + 4.0 + 2.6 + 5.1 + 3.5 + 4.4 = 22.8, and 22.8 ÷ 6 = 3.8 hours. School 4: 5.1 − 3.8 = 1.3 hours too high.

Reflect and check

Asking 500 students did not help: they all came from one school, and the schools differ. A cluster sample works when each cluster looks like the whole. If every school had the same mix, one school would land near 3.8.

The Same Idea in Python

Not part of class today: try it at home. Press ▶ Run under each cell, in order. Say your guess first. On this page the school file is already here, so no Choose files button shows. No pandas word is new: .sample came in L20 and L24.

1from google.colab import files 2import pandas as pd 3name = next(iter(files.upload())) 4df = pd.read_csv(name) 5print(round(df["sleep"].mean(), 2))

In Sheets this is: =AVERAGE(SCHOOL!D2:D101) in G6 of your L25 tab: the true mean, all 100 students.

In English:

  1. Get the tool that opens files.
  2. Get the pandas toolbox and call it pd.
  3. Show a Choose files button, and call the name of the file you pick name.
  4. Open the file as a table called df.
  5. Print the mean of the sleep column, rounded to 2 places.

Predict: all 100 students are the population. What is their mean sleep, in hours? Your G6 has it.

Can’t run it here? Show what it prints
7.3

In Sheets this is: =AVERAGE(D2:D11) in G2: the first 10 rows of the shuffled school, a simple random sample.

In English:

  1. Take 10 of the sleep column’s rows at random, and call them ten.
  2. Print the mean of ten, rounded to 2 places.

Predict: will it print the same number as Cell 1? Run it again. Then click in the cell, change 10 to 40 and run it twice more.

Can’t run it here? Show what it prints
7.19

Yours will differ: a new 10 every run. Most runs land from about 6.9 to 7.7, a little high or a little low. With 40, from about 7.1 to 7.5.

Want to type your own? The Python practice page has tasks and a notebook.

In your project

Your claim is about the rows in your file, so a reader needs to know how those rows were picked. None of the four project files is a random sample: each holds every row of a place and a time someone chose. ABOUT A7 says so, and the rubric’s Data Acquisition row asks for it. A big file also gets a SAMPLE tab: today’s simple random sample, 300 rows of your own CLEAN, which L27 uses on Wednesday.

Check Yourself

Answer each one before you look. The first two are from L24 and L22.

A sample’s mean is 12.4. The true mean is 13.0. What is the sample’s bias? L24

A2 to B7 hold homeroom and sleep: 1, 6.5; 2, 8.0; 1, 7.5; 2, 9.0; 1, 6.0; 2, 7.0. What does =AVERAGEIF(A2:A7,2,B2:B7) show? L22

A survey takes every 5th name on a roster of 200, from a random start among the first 5. Which way is this?

A list has 360 names. A systematic sample takes 30 of them. Every how many names?

A club has 250 members: 100 juniors and 150 seniors. A stratified sample of 20 takes each group in proportion. How many seniors?

Four homerooms of the same size average 6.0, 7.0, 8.0 and 9.0 hours of sleep. A cluster sample picks the homeroom that averages 9.0. What is its bias?

Which is a cluster sample of a school’s students?

A poll must ask 30 women and 30 men. Its interviewers ask whoever walks by. What goes wrong?

A town’s neighborhoods differ a lot in income, and each one must be in the survey. Which way fits best?

Project Checkpoint

SAMPLE · L27 uses it Wed 16 Dec · ABOUT A7 · part of P2, due Fri 18 Dec

Your claim holds for the rows your file holds. A7 tells a reader how those rows were picked, so nobody reads your file as a random sample of more than it is. SAMPLE is a random 300 of your own rows: on Wednesday you check a share on it against all of CLEAN.

My datasetCLEAN rowsSAMPLE?ABOUT A7
Colleges1,972NoSampled: no. Every college that reported admissions to IPEDS for 2023.
Bikeshare trips36,574YesSampled: no. Every trip that started at 99 stations in September 2025.
Weather10,958YesSampled: no. Every day from 1995 to 2024, at one station.
Trail counters1,011NoSampled: no. Every day of 2024, at 3 counters the county placed.

The SAMPLE formula, in A2: =ARRAY_CONSTRAIN(SORT(FILTER(CLEAN!A2:B,ISNUMBER(CLEAN!B2:B)),RANDARRAY(COUNT(CLEAN!B2:B),1),TRUE),300,2). Read it from the inside out. FILTER keeps columns A and B of each row whose B is a number, so the empty rows below your data stay out. COUNT counts those rows, and RANDARRAY gives each one a random number. SORT puts the rows in that order: a shuffle. ARRAY_CONSTRAIN keeps the first 300 rows and both columns. Then freeze A2 to B301: copy, Edit > Paste special > Values only. Where everything goes: your Sheet, tab by tab.

Read More

OpenStax, Introductory Statistics 2e, section 1.2: Data, Sampling, and Variation in Data and Sampling. A free college textbook. Its part on sampling names all four ways, with examples, and then convenience samples, the kind a person chooses.

Stuck on any of this? Ask Mr. Case in class or send him a message in Canvas. Name the example or the question number, and say which step lost you.