L17 Catch the Ruler

DATA SCIENCE · CYCLE 2 · L17 · TEXTBOOK CHAPTER

Catch the Ruler

In class, pairs caught a falling ruler and asked what a typical catch is. There are two ways to say what is typical: the mean and the median. One value far from the rest pulls the mean a lot and barely moves the median.

After this chapter, you can

For your project: the mean and the median of your number go on ANALYSIS. The checkpoint is at the end.

Why It Matters

Drawing of a street of small houses with one very large mansion in the middle
One very large house moves the street’s mean. It barely moves the median.

The Census Bureau reports a typical US household’s income for 2023 as $80,610. That is a median.

The same report gives the mean: $114,500. The mean is $33,890 higher than the median. So why does the report give the median first? Six made-up households show why.

Five householdsAdd one very rich household
Incomes$40,000, $60,000, $80,000, $100,000, $120,000the five and $10,000,000
Mean$80,000$1,733,333
Median$80,000$90,000

One household moved the mean by more than $1.6 million. It moved the median by $10,000. A typical household is the middle one, so the report gives the median first.

The real numbers work the same way. The households with the largest incomes pull the mean up to $114,500. The middle household is at $80,610.

The Idea

Two ways to say what is typical

The mean is the total shared out evenly. The median is the middle value once they are in order. Each one is a center: one number for what is typical. With an even count, the median is the mean of the two middle values.

CenterHow to find itAn outlier
meanadd them all, divide by how manypulls it a lot
medianput them in order, take the middlebarely moves it

When a few values sit far out, the median describes a typical one.

An outlier is a value far from the rest. The mean uses the size of every value, so one outlier pulls it. The median uses only the order. An outlier just becomes the biggest value, and the middle barely moves.

Sheets calls the mean AVERAGE. When people say “the average”, they mean the mean.

The Shape Tells You Which Is Bigger

A histogram is bars that count how many values fall in each range. This one shows the weights in the class file from L17.

05001,0001,5002,00030 to 35: 6 students35 to 40: 40 students40 to 45: 328 students45 to 50: 999 students50 to 55: 1,538 students55 to 60: 1,830 students60 to 65: 1,649 students65 to 70: 1,537 students70 to 75: 1,385 students75 to 80: 847 students80 to 85: 659 students85 to 90: 478 students90 to 95: 312 students95 to 100: 334 students100 to 105: 176 students105 to 110: 113 students110 to 115: 126 students115 to 120: 58 students120 to 125: 52 students125 to 130: 45 students130 to 135: 28 students135 to 140: 14 students140 to 145: 5 students145 to 150: 9 students30507090110130150median 64.4 kgmean 67.9 kgWeight (kg)Students (count)
Weight of 12,579 students, CDC Youth Risk Behavior Survey. Each bar is 5 kg wide. The solid line is the median and the dashed line is the mean. 11 students outside 30 to 150 kg are left off.

Most students are in the bars from 45 to 80 kg. A thin run of bars stretches right, as far as 150. That is a long tail of big values, so the data are skewed right.

The few students who weigh much more pull the mean toward the tail. The median is the middle student and barely moves. So the mean, 67.9 kg, sits above the median, 64.4 kg.

Worked Examples

Example 1 · The mean and the median by hand. Mia sent 23, 8, 31, 14 and 9 texts on five school days. Find the mean and the median.

Create a strategy

Mean: add them all, then divide by how many. Median: put them in order first, then take the middle.

Apply the idea

Mean: 23 + 8 + 31 + 14 + 9 = 85, and 85 ÷ 5 = 17. Mean = 17 texts.

In order: 8, 9, 14, 23, 31. There are five values, so the middle is the third. Median = 14 texts.

Reflect and check

The middle of the list as Mia wrote it is 31, the biggest value. That is why you put the values in order first. Check it in Sheets: type the five values in A1 to A5, then =AVERAGE(A1:A5) in C1 and =MEDIAN(A1:A5) in C2. They show 17 and 14.

Example 2 · What one outlier does. A school club posted five videos. They got 40, 52, 55, 61 and 67 views. Then a sixth video got 925 views. What happened to the mean and to the median?

Create a strategy

Find both centers for the five videos, then for all six. Six is an even count, so the median is the mean of the two middle values.

Apply the idea
Five videosAll six videos
Add them all40 + 52 + 55 + 61 + 67 = 275275 + 925 = 1,200
Mean275 ÷ 5 = 551,200 ÷ 6 = 200
Medianthe third value, 55(55 + 61) ÷ 2 = 58

There are six values now, so divide by 6. The mean moved 145 views. The median moved 3 views.

Reflect and check

The 925 is an outlier. Five of the six videos got fewer than 200 views, so the mean no longer describes a typical video. The median, 58 views, does. The 925 is a real count, so it stays in the data. You report the median, and you say why.

Try It: Move One Value

The lab starts on six new values. The solid line is the median and the dashed line is the mean. Change a value and watch which line moves. Then meet the three goals.

In Sheets: AVERAGE, MEDIAN and a Histogram

The same steps as in class, on the class file. Column G is weight, in kilograms.

  1. Download L17-YRBSS.csv.
  2. Open Google Sheets.
  3. Click Blank spreadsheet.
  4. File > Import > Upload > Browse.
  5. Pick L17-YRBSS.csv.
  6. Import location: Insert new sheet(s).
  7. Import data.
  8. Click cell N1. Type: =AVERAGE(G2:G13584)
  9. Click cell N2. Type: =MEDIAN(G2:G13584)
  10. Click the column G letter.
  11. Insert > Chart.
  12. On Setup, set Chart type to Histogram chart.

N1 shows the mean, 67.9 to one decimal place. N2 shows the median, 64.4. The chart has the same long tail to the right as the histogram above.

1,004 rows say NA in column G. =AVERAGE and =MEDIAN skip text, so they use the 12,579 weights that are numbers. If N1 shows 1.69, you picked column F, height in meters.

The Same in Python

Python comes in L19b, later in this cycle. Once you have read it, come back and run Example 2’s six videos here.

In Sheets this is: =AVERAGE(A1:A6) and =MEDIAN(A1:A6).

In English:

  1. Get the pandas toolbox and call it pd.
  2. Make a column of the six numbers, and call it views.
  3. Print the mean of views.
  4. Print the median of views.

Predict: Example 2 found both by hand. What will lines 3 and 4 print? Then change the 925 to 70, say which line will change more, and run it again.

Can’t run it here? Show what it prints
200.0 58.0

pandas writes a whole mean or median as a decimal: 200.0 and 58.0 are the 200 and the 58 from Example 2. With 70 in place of 925 it prints 57.5 and 58.0. The mean dropped by 142.5, and the median stayed.

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

In your project

Three pieces of your Cycle 2 project’s ANALYSIS tab come from this chapter: a histogram, the mean and the median of your number column. Make the histogram first and look for a tail. If it has a long tail, report the median first, and say why: a few far values pull the mean. If the mean and the median are close, either one describes a typical value.

A mean far from the median is also a warning. Look for a value typed wrong. Fix it on your CLEAN tab and write the fix on your LOG tab.

Check Yourself

Answer each one before you look. The first two are from L15 and L16.

Every line of a file looks like this: Leo;16;Room 8. You name the separator yourself. Which Separator type do you choose? L15

A file of bus trips has one row a trip. Bus 12 is on 40 rows, each with its own date. Are those 40 rows duplicates? L16

Find the mean of 4, 9, 6, 13 and 8.

Find the median of 21, 7, 30, 15 and 12.

Six plants grew 1, 3, 7, 12, 16 and 19 cm in a month. Find the median, in centimeters.

Five tips at a cafe, in dollars: 2, 3, 4, 5, 6. Their mean is 4. A sixth tip of 40 comes in. What is the new mean?

One value far from the rest joins a list. What does it do to the two centers?

Seven pizza deliveries took 18, 19, 20, 21, 22, 23 and 24 minutes. The mean is 21 and the median is 21. Which center describes a typical delivery?

A column holds 500 wait times. =AVERAGE gives 48 minutes and =MEDIAN gives 31 minutes. What does the histogram most likely show?

Project Checkpoint

ANALYSIS · part of P2, due Fri 18 Dec

Your claim reports a typical value for each group. The mean and the median are two ways to say typical, and a mean far from its median warns you that a few far values, or a typo, are pulling it.

Do these once your CLEAN tab exists (L22, Fri 4 Dec). Column B of CLEAN is your number.

Check these numbers in Python: Your Project File on the practice page opens your CLEAN tab and prints them.

Tick each step once it is in your Sheet. Your ticks go into the PDF you hand in. Where everything goes: your Sheet, tab by tab.

Read More

OpenStax, Introductory Statistics 2e, section 2.5: Measures of the Center of the Data. A free college textbook. Read as far as Example 2.27: a town of 50 people where one person earns $5,000,000 and the other 49 earn $30,000 each. The mean is $129,400 and the median is $30,000. The section also names a third center, the mode: the most frequent value.

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.