L26 Scoop the Beans

DATA SCIENCE · CYCLE 2 · L26 · TEXTBOOK CHAPTER

Scoop the Beans

Scoop a bowl twice and you get two different shares. That wobble is chance, and it has a rule: it shrinks with the square root of the sample size. Small groups wobble most, so they land at both ends of any ranking.

After this chapter, you can

For your project: one sentence under your group table that says which group’s mean rests on fewer rows, and so wobbles more. The checkpoint is at the end.

Why It Matters

In the late 1990s the Gates Foundation began paying for small schools across the country. By 2001 its grants for education came to about $1.7 billion. Other foundations and the U.S. Department of Education joined in, and cities split big high schools into small ones.

The reason was a pattern: small schools showed up among the top scorers more than their share. Howard Wainer and Harris Zwerling looked at all 1,662 Pennsylvania schools with 5th grade test scores. Of the 50 top scorers, 6 were among the smallest 3% of schools: 6 ÷ 50 = 12%, four times the 3% you would expect if size did not matter.

Then they looked at the 50 lowest scorers. 9 of them were among the 50 smallest schools: 9 ÷ 50 = 18%. Small schools were at both ends. Overall, size made no difference to 5th grade scores. A small school’s mean rests on few students, so it swings more by chance, high or low. In 2005 the Gates Foundation moved away from splitting big schools.

Wainer calls the rule behind this the most dangerous equation, because not knowing it has cost so much. It says how much a mean wobbles: its standard error is the SD divided by the square root of the sample size.

standard error = SD ÷ √n

The Idea

Bigger samples wobble less

A sample’s share or mean wobbles from sample to sample. Bigger samples wobble less. The wobble shrinks with the square root of the sample size.

The sample growsSquare rootThe wobble is
4 times√4 = 2half
9 times√9 = 3a third
100 times√100 = 10a tenth

So small groups land at both ends, the top and the bottom, by chance. How much a share or mean changes from one sample to the next is its sampling variability. Its SD over many samples is the standard error.

Try It: Scoop Without Looking

Here is the class’s bowl of 1,000 beans, the same as your BOWL tab. Some are red. You cannot see in. Press Scoop 25 a few times and watch the share red change. Then press Scoop 100. Then press 20 of each. Which row spreads wider? Guess the bowl’s share before you press Show the bowl.

Worked Examples

Example 1 · How many to ask. A poll of 100 voters gives a share with a standard error of 5 points. The pollster wants 2.5 points. How many voters? For 1 point?

Create a strategy

The wobble shrinks with the square root of the sample. To divide the wobble by k, multiply the sample by k × k.

Apply the idea

5 to 2.5 divides by 2, so multiply by 2 × 2 = 4: 100 × 4 = 400 voters. 5 to 1 divides by 5, so multiply by 5 × 5 = 25: 100 × 25 = 2,500 voters.

Reflect and check

Check backward: √400 ÷ 100 = √4 = 2, and √2,500 ÷ 100 = √25 = 5. Each step of sureness costs more people than the last.

Example 2 · Two hospitals. A small hospital has 15 births a day and a big one has 45. About half of all babies are boys. Over a year, which hospital has more days when more than 60% of the babies born are boys?

Create a strategy

A day’s share of boys is a sample’s share. The smaller sample wobbles more, so it lands far from half more often. Find how many times as much.

Apply the idea

45 ÷ 15 = 3, so the small hospital’s share wobbles √3 ≈ 1.7 times as much. Worked exactly: the small hospital needs 10 or more boys of 15, which happens on about 15% of days, or 55 days a year. The big one needs 28 or more of 45: about 7% of days, or 25 days.

Reflect and check

Every baby has the same chance in both hospitals. Only the size of the day’s sample differs, and the small one has more than twice as many lopsided days. It also has more days with too few boys.

Example 3 · One case in a small county. Wainer looked at kidney cancer rates for every U.S. county. A rate is cases per 100,000 people. Big counties all sit near 5 per 100,000. Take a county of 100 people.

Create a strategy

Rate = cases ÷ people × 100,000. Work it for 0 cases and for 1 case.

Apply the idea

0 cases: 0 ÷ 100 × 100,000 = 0, the lowest rate there is. 1 case: 1 ÷ 100 × 100,000 = 1,000 per 100,000, far above the big counties’ 5.

Reflect and check

One person moves this county from the bottom of the list to the top. In a county of 1,000,000, one more case moves the rate by 1 ÷ 1,000,000 × 100,000 = 0.1. Wainer found the healthiest counties and the least healthy were mostly the same kind: small and rural.

Run It: Scoop in Python

Press ▶ Run under each cell, in order. Say your guess first. On this page the bowl file is already here, so no Choose files button shows. Cells 1 to 3 use words you know: .sample came in L20 and L24. Cell 4 brings one new toolbox, numpy, for 1,000 scoops at once.

1from google.colab import files 2import pandas as pd 3name = next(iter(files.upload())) 4df = pd.read_csv(name) 5bowl = df["red"] 6print(len(bowl), "beans")

In Sheets this is: File > Import of L26-bowl.csv, the BOWL tab, and its named range bowl.

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. Take the red column, and call it bowl: 1 is a red bean, 0 is not.
  6. Print how many beans are in the bowl.

Predict: how many beans?

Can’t run it here? Show what it prints
1000 beans
1scoop = bowl.sample(25) 2print(scoop.mean())

In Sheets this is: =AVERAGE(A1:A25) in A27 of your L26 tab: one scoop of 25 beans, its share red.

In English:

  1. Take 25 of the bowl’s beans at random, and call them scoop.
  2. Print the mean of scoop: its share red.

Predict: run it five times. Each run is a new scoop. From your five shares, what share of the bowl do you think is red?

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

Yours will differ: a new scoop every run.

1print(bowl.mean())

In Sheets this is: =AVERAGE(bowl) in V25: the reveal.

In English:

  1. Print the mean of the whole bowl: its share red.

Predict: is it near your guess?

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

In Sheets this is: 1,000 columns like A1:T25 on your L26 tab, each column’s =AVERAGE, then =STDEV of the 1,000 shares. Your V23 does it for 20.

In English:

  1. Get the numpy toolbox, for random numbers in bulk, and call it np.
  2. Call the scoop size n, and make it 25.
  3. Scoop n beans 1,000 times from a bowl as red as this one, putting each bean back. Count the red in each scoop, and call the 1,000 counts reds.
  4. Divide each count by n, each scoop’s share red. Make the 1,000 shares a column called shares.
  5. Print the SD of the 1,000 shares, rounded to 3 places.

Predict: near what SD? Your V23 is one Sheet’s answer. Then change 25 to 100 and run it again: about what SD now?

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

Yours will differ a little: most runs print from 0.095 to 0.102. Change 25 to 100 and most print from 0.047 to 0.051, half as much.

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

In your project

Your claim compares two group means, and each rests on its own count of rows: B7 and B8 on ANALYSIS. The mean on fewer rows wobbles more, so part of any gap between your groups can be chance. A9 says which mean that is. In January the shuffle test asks how big a gap chance can make.

Check Yourself

Answer each one before you look. The first two are from L25 and L20.

A school has 900 students, 300 of them in grade 9. A stratified sample of 45 takes each grade in proportion. How many come from grade 9? L25

A1 to A8 hold a scoop of 8 beans, 1 for red: 1, 0, 0, 1, 0, 0, 0, 0. What does =AVERAGE(A1:A8) show? L20

Scoops of 35 beans give shares with an SD of 0.09. About what SD do scoops of 140 give?

To cut the standard error to a third, the sample must be how many times as big?

A club’s mean rests on 24 members. A school’s mean rests on 600 students. How many times as much does the club’s mean wobble?

Why do the smallest schools show up at both the top and the bottom of a state’s test rankings?

Poll A asks 100 people. Poll B asks the same question of 400 people. Which is right?

A scoop of 25 from one bowl is 0.64 red. A scoop of 100 from another bowl is 0.62 red. Which is better evidence that its bowl is more than half red?

Project Checkpoint

ANALYSIS A9 · part of P2, due Fri 18 Dec

Your claim rests on two means. If one rests on far fewer rows, it can sit high or low by chance, and a reader should know that before trusting the gap. A9 says which mean wobbles more, in one sentence with both counts.

My datasetA7, A8 and their countsA9, for example
Collegesprivate 1,362 and public 610My public mean rests on 610 rows and my private mean on 1,362, so the public mean wobbles more.
Bikeshare tripscasual 12,281 and member 24,293My casual mean rests on 12,281 rows and my member mean on 24,293, so the casual mean wobbles more.
Weatherbefore 2010 5,479 and since 2010 5,479Both my means rest on 5,479 rows, so they wobble about the same.
Trail countersweekday 723 and weekend 288My weekend mean rests on 288 rows and my weekday mean on 723, so the weekend mean wobbles more.

Your own two groups, two months or two counters? Use your own B7 and B8. Equal counts: the two means wobble about the same. How many times as much does the smaller one wobble? The square root of the bigger count over the smaller: √723 ÷ 288 ≈ 1.6 for the trail counters’ weekends. Where everything goes: your Sheet, tab by tab.

Read More

OpenStax, Introductory Statistics 2e, section 7.1: The Central Limit Theorem for Sample Means. A free college textbook. It shows the standard error as the SD divided by the square root of n, and why bigger samples give means that bunch closer to the truth.

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.