← Dashboard

data science / statistics

Statistics for Data Analysis: Why the Average Lies, With Worked Examples

This is the applied side of statistics: reading a summary number critically before you act on it. Two small datasets show an average that describes nobody and a result that reverses when you split the data, and a table of checks tells you what to run first. Free books and courses follow.

updated Nov 2026·an 11-minute read·examples computed with pandas 3.1

A working analyst spends little time proving theorems and a lot of time deciding whether a number can be trusted. That skill is a set of habits more than a body of math: look at the distribution before the mean, ask what groups the data hides, and be suspicious of any single figure offered without its spread. If you want the university-course route instead, with ordered syllabi from MIT, Harvard and Stanford, that lives on the CS statistics page. This page is for people who have a spreadsheet or a DataFrame open right now.

01 · A MISLEADING AVERAGE

Ten salaries, one average, and nobody earns it

A startup advertises that its employees earn an average of $85,800. Here are the ten salaries behind the claim, in thousands of dollars: 42, 45, 47, 48, 50, 52, 55, 58, 61 and 400. The 400 is the founder.

average.pypandas 3.1
import pandas as pd
s = pd.Series([42, 45, 47, 48, 50, 52, 55, 58, 61, 400], name="salary_k")
print(s.mean(), s.median(), s.std().round(1))
print((s < s.mean()).sum(), "of", len(s), "below the mean")
trimmed = s.drop(s.idxmax())
print(trimmed.mean().round(1), trimmed.median(), trimmed.std().round(1))
What it prints
MeasureAll tenWithout the founder
Mean85.850.9
Median51.050.0
Standard deviation110.66.2
Employees below the mean9 of 10-

One value moved the mean by almost 35 while moving the median by 1. The standard deviation (110.6) is bigger than the mean, which is itself a warning that the distribution is lopsided. In skewed data such as salaries, home prices and response times, report the median, and show the spread or the percentiles next to it. Series.describe() gives the quartiles in one call, and the pandas reference documents the options.

02 · THE SPLIT THAT REVERSES

When the better design loses overall

A product team tests two checkout designs on 1,000 visitors each. Design B converts better on desktop and better on mobile, yet Design A wins in the totals. This is Simpson's paradox, and the numbers below are constructed (they illustrate the effect, they are not a real study):

Orders per visitor, by design and device
DesignDeviceVisitorsOrdersRate
Adesktop8009612.0%
Amobile20063.0%
Bdesktop2002814.0%
Bmobile800405.0%
A overall1,00010210.2%
B overall1,000686.8%

B wins on each device (14.0 vs 12.0 on desktop, 5.0 vs 3.0 on mobile), but B's traffic was mostly mobile, where everyone converts poorly, while A's was mostly desktop. The overall rate mixes two populations of very different quality. Which number is right depends on the question. If device mix is a fact you cannot change, compare within device. If you control who sees which design, the test was badly randomized and should be rerun with equal mixes.

WATCHA total is an average over groups. Whenever one group is much larger in one arm than in the other, group the comparison by that variable before drawing a conclusion.

03 · BEFORE YOU REPORT A NUMBER

Six checks, in the order to run them

A pre-flight list for any summary statistic
CheckHowWhat it catches
Look at the shapeHistogram or describe()Skew, outliers, impossible values
Median next to meanCompare the twoSkew pulling the mean around
SpreadStandard deviation, IQR, percentilesA mean that hides wide variation
Sample sizecount() per groupAverages built on a handful of rows
Segment by the obvious variablegroupby device, region, monthSimpson's paradox, mix shifts
UncertaintyConfidence interval or a test from scipy.statsDifferences that are just noise

For the last check, SciPy's statistics tutorial covers distributions and hypothesis tests with runnable examples. The caveat is the theme of Alex Reinhart's book: a p-value answers a narrow question and is easy to misuse, and the book's chapters cover stopping rules, truth inflation and hiding the data.

04 · FREE MATERIAL

Books and courses for applied analysis

Choose one book as your spine and use the others as second explanations. The first group assumes you can read a little Python or R code.

If you prefer video and visuals, these three work well beside a book.

05 · TRY IT

Audit a number you already trust

TRY ITPick any dataset with a numeric column and a category, such as rent by neighborhood or delivery times by day. Print the mean and median side by side, then compute both again per category. If the two overall figures disagree by more than a few percent, or if a category ranking flips between mean and median, write one sentence explaining which statistic you would report and why. Then read the introduction of Statistics Done Wrong and compare its warnings to what you found.

06 · FAQ

Frequently asked questions

Should I report the mean or the median?

Report the median when the data is skewed, as with salaries, prices or response times, because a few extreme values drag the mean away from typical cases. Show the spread or percentiles beside it. The mean is fine for roughly symmetric data without large outliers.

What is Simpson's paradox?

It is when a trend that holds inside every subgroup reverses once the groups are combined. It happens when group sizes differ between the things being compared, as when one checkout design gets mostly mobile visitors who convert less. Compare within groups, or fix the mix.

How much statistics do I need for data analysis?

Enough to describe distributions, compare groups, understand uncertainty and avoid common errors such as misreading p-values. Descriptive statistics, sampling, confidence intervals, hypothesis tests and basic regression cover most analyst work.

What is the best free book for learning applied statistics?

Think Stats suits readers who know some Python, ModernDive suits R users, and OpenIntro Statistics is a conventional textbook with a free PDF. Add Statistics Done Wrong as a short guide to common mistakes.