What does an average hide? Mean vs. median
Find out why a bar of averages hides how the values are spread, and change a chart to see every ticket instead of a single number.
Free course. Your Maestro, an AI, .
Monday's report has a simple chart: two bars of the same height. "Average Saturday ticket: Centro 95 pesos, Zapopan 95 pesos." Below it, the manager's conclusion: both branches have the same customer, so we'll send them the same promotion.
You already saw these numbers in module 2, with a histogram. This page doesn't repeat that lesson: it teaches you to recognize the trap when you aren't given the histogram, only the bar with the average, which is what happens almost every time in a report.
What an average does
The average (the mean) adds up all the values and divides by how many there are. At both branches, 11,400 pesos were sold in 120 tickets: 11,400 divided by 120 is 95. The math is right. The problem is what the bar leaves out: how those 11,400 pesos are spread.
A bar of averages turns a hundred or a thousand values into one. Many very different spreads give the same average:
- 120 tickets of 95 pesos each.
- 108 small tickets and 12 very big ones.
- 60 tickets of 45 pesos and 60 of 145.
All three give 95. And they call for different decisions: a promotion for the 95-peso customer is no use to anyone in the second case.
That's why there's another measure, the median: you sort all the values from smallest to largest and take the one in the middle. Half the tickets fall below it and the other half above. If the average and the median are close, the values are probably bunched around the center. If they're far apart, a few extreme values are pulling the average.
Try it
This is the report's chart, lying on its side: one bar per branch with the average. You're going to change it so it shows every ticket as a little tick mark, instead of a single number per branch.
This time I'll give you the goal and a few hints, not the exact changes. The goal: make the chart draw each ticket as a short tick mark, instead of a bar with each branch's average. It takes three changes (the columns are in Spanish: montomxn is the ticket amount in pesos, sucurs
Your turn
This time I'll give you the goal and a few hints, not the exact changes. The goal: make the chart draw each ticket as a short tick mark, instead of a bar with each branch's average. It takes three changes (the columns are in Spanish: monto_mxn is the ticket amount in pesos, sucursal the branch):
- The mark. Right now it draws bars (
mark_bar()); in Altair, the short tick mark is called a tick. - The average. Find which part of the
xline asks the chart to take the average (mean), and remove it so each ticket stays in its place. - The title. The axis no longer measures an average: change its title ("Ticket promedio" means average ticket) so it says what it measures now.
You're done when you see two rows of tick marks, one per branch. Before you read on, find where 95 pesos would fall in each row. If you get stuck, ask your Maestro for a hint, not the answer; if you get an error, paste it in.
The chart redraws when you pause typing, or right away with Run. Ctrl+Enter runs it. Tab indents; to leave the editor, press Escape, then Tab.
Ready to run your code.
Data: tickets-sabado, 240 rows
Enter saves a cell and Escape leaves it as it was. Leave a cell empty for a missing value.
| Row | Remove | ||
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | |||
| 7 | |||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 |
With three changes, the same information tells another story.
At Centro, the tick marks form a single group: they range from 44 to 147 pesos, and half the tickets fall between 84 and 106. The average, 95, sits in the middle of the group, and the median is 96. There, yes, the customer who spends about 95 pesos exists and is the most common.
At Zapopan, the tick marks split in two. Almost all of them pile up on the left: 108 of the 120 tickets are under 80 pesos. Then there's a huge gap, and on the right are 12 tickets of 400 pesos or more, the biggest one 593. The median is 54.5. And the average of 95? It lands right in the gap: there isn't a single Zapopan ticket between 80 and 400 pesos. Zapopan's "average customer" doesn't exist.
The report's bar didn't lie about its number. It lied about what it invited you to conclude.
Why did Zapopan's average end up so far above the median? Ask your Maestro to explain it with these numbers.
What to ask for when you're only given an average
You won't always have the data to make the chart yourself. But you can ask questions:
What's the median?
If it's close to the average, the values are bunched together. If it's far away, a few extreme values are pulling the average.
What are the smallest and the largest?
At Centro, from 44 to 147 pesos. At Zapopan, from 27 to 593. The same average with such different ranges is already a warning sign.
How many cases is it based on?
An average of 5 cases and one of 5,000 don't carry the same weight. With few cases, a single one moves it a lot.
Can I see all the values?
Ask for a histogram or a tick-mark chart like the one you just made. With that you can see the groups, the gaps and the extreme values.
When the chart is yours, the rule is the one from module 2: if the question is how the values are spread, show the spread, with a histogram or with every point. A bar of averages answers a different question, "how much is it on average?", and it's almost never the one that matters for deciding.
This happens with any average: the average salary at a company where the director earns a hundred times more than everyone else, the average delivery time when a few orders get lost for a week, the average grade of a class where half failed and the other half got perfect scores.
Have an average from work that makes you suspicious? Tell your Maestro where it comes from and ask what you'd check.
Check yourself: A courier company tells you: "Our average delivery time is 2 days." You need your orders to arrive in under 3 days. What should you ask before hiring them?
You now have the four traps in this module: the cut axis, the dual axis, the areas that exaggerate and the average that hides. The course's last page tests you with the three questions from the beginning and a chart to fix on your own.
Before you move on, ask your Maestro for a misleading average for you to take apart.