Interactive statistics

56 free interactive lessons: from mean and median to A/B tests and Bayes. Drag the charts and build intuition. No sign-up.

Module 1: Descriptive statistics

Spread and standard deviation

The "Mama John's" chain has grown to two locations. The average salary at both is exactly 35k: at pizzeria A everyone earns roughly the same, at pizzeria B some earn much less, some much more. Same mean β€” completely different teams. To catch that difference you need a second characteristic: how far the values scatter around the center.

Pizzeria A (even)Οƒ = 6.1 k263033374044Pizzeria B (contrasting)Οƒ = 14.5 k132333374757
Pizzeria A (even): mean 35.0 k, Οƒ 6.1 kPizzeria B (contrasting): mean 35.0 k, Οƒ 14.5 k

Two pizzerias, both with an average salary of exactly 35k β€” the dashed line sits in the same spot in both rows. But the points of Pizzeria B are scattered noticeably wider than A's. To the right of each row is its Οƒ ("sigma"), the measure of spread this whole lesson is about.

What it means

Back to our two pizzerias. Both have the same average salary β€” 35k β€” but Οƒ is about 6 at Pizzeria A and about 14 at Pizzeria B. The center coincides, yet life inside is completely different: at Pizzeria A salaries are predictable and stay close together, at Pizzeria B the gap between people is huge.

Hence the main takeaway of the lesson: the center is almost never looked at alone. "Mean plus spread" is the minimal honest pair that describes data: where it concentrates and how widely it diverges around that center.

Where it shows up

Spread is everywhere that not only the magnitude but also the stability matters. Two couriers deliver in 30 minutes on average, but one stays within 25–35 while the other jumps from 10 to 60: same mean, different reliability β€” and Οƒ shows it at once.

The same underlies the volatility of stocks (that is the Οƒ of returns: the larger, the riskier) and quality control in manufacturing, where "beyond 3Οƒ" is treated as a defect (why exactly 3 β€” we'll see in the normal distribution lesson).

Next we'll look at what shapes data takes at all. There the mean and Οƒ come into their own together: for a bell-shaped, "normal" distribution they almost fully define it.

Definitions
Deviationxiβˆ’xΛ‰x_i - \bar{x}
The difference between a single value and the mean. It shows how far that value sits from the center, and in which direction.
In plain words: how far a particular value has strayed from the mean.
VarianceΟƒ2=βˆ‘(xiβˆ’xΛ‰)2N\sigma^2 = \dfrac{\sum (x_i - \bar{x})^2}{N}
The mean of the squared deviations from the mean. Squaring removes the signs and penalizes distant values more heavily. It is measured in squared original units, so it is usually not read directly β€” you take its square root instead. The formula above is for the whole population; for a sample (i.e. almost always) it is adjusted slightly β€” see the optional deep dive below.
In plain words: the average squared deviation from the mean.
Standard deviation (Οƒ)Οƒ=βˆ‘(xiβˆ’xΛ‰)2N\sigma = \sqrt{\dfrac{\sum (x_i - \bar{x})^2}{N}}
A measure of how widely the values are scattered around their mean. It is the square root of the variance, so it is expressed in the same units as the data and reads as the "typical deviation from the mean".
In plain words: the typical distance from a point to the mean, in ordinary units.
Coefficient of variationCV=σxˉCV = \dfrac{\sigma}{\bar{x}}
The standard deviation divided by the mean β€” the spread as a fraction (or percentage) of the mean. It is independent of the units, so it lets you compare variability across quantities of different scale.
In plain words: the spread as a percentage of the mean β€” comparable across different quantities.
When the method lies (assumptions)

Standard deviation relies on the mean, so it inherits its weakness: one strong outlier inflates Οƒ so much that the "typical spread" stops describing typical data. For skewed quantities (incomes, response times) it is more honest to look at spread through percentiles.

Deep dive: the math and the mechanism (optional)

Working through the derivation below isn't required. For practice, one fact is enough to remember: if you're computing variance or Οƒ on a sample (which is almost always the case), the denominator should be nβˆ’1, not n.

The formula in the definition above is for the whole population, where the mean is known in advance and doesn't depend on the data itself. In practice, though, we compute the mean from the very same sample we're measuring spread on, and that quietly fits the data to its own mean. Because of this, the sum of squared deviations comes out a bit smaller than it honestly should be, and the /N formula systematically underestimates the population's spread.

To remove this bias, sample variance uses nβˆ’1 in the denominator instead of n. One way to see why: once you've fixed the mean from n values, only nβˆ’1 of them are free to vary β€” the last one is already determined, since you can always back it out from the rest plus the mean. Hence the name: degrees of freedom.

This is exactly why the same numbers sometimes give a different Οƒ in different tools. Excel and pandas divide by nβˆ’1 by default (the sample calculation), while numpy divides by n by default, and you have to explicitly ask for nβˆ’1. It's not a bug or a discrepancy β€” it's two different questions: how spread out is THIS data (n), or what does this data say about spread in the whole population (nβˆ’1). In analytics you almost always need the second answer.

Next β†’
Enjoying the materials?

This site is built by the DataSlice Telegram channel: data analytics in plain words β€” real cases, metrics, careers. The channel is in Russian.

Open the Telegram channel