A sample is not the whole truth: minimal statistics
Why the number from a sample is not the true one, how much it changes, and why pure chance can look like a trend. AI course, 1.3.

AI from the First Bit › Level 1 — Uncertainty: the raw material of AI part 3 of 4
What we know about an AI system usually comes from trying it on a few examples: a sample. And the number a sample gives is not the true value, because another sample, drawn from the same place, would give a different number. For the same reason, a series of random results can look like a trend.
Try this first
Open the CLT simulator in the Statistics tool (CLT is the central limit theorem, explained below), with the Exponencial population (exponential; the menu keeps the Spanish spelling), sample size 30, 3000 samples and seed 1. When it opens, the tool runs the experiment by itself. The population is an invented list of values that follow an exponential distribution: many small values and a few very large ones, like the minutes between one customer and the next in a shop or the time a server takes to answer. On the left, Starting population: how those values are spread. On the right, Sample means: the result of the experiment.
The tool’s exponential population has a mean of 1: it is the true value, the one we would like to find out. The tool writes it at the top as “Population: 1 · σ 1”: the population mean is 1 and its standard deviation, σ (the Greek letter sigma), is also 1; the dot only separates the two figures. The standard deviation is how far a value usually strays from the mean, as explained in Chance and distributions. The true mean is also marked by a red line on the chart on the right.
The tool acts as if it did not know it: it draws 30 values at random and computes the mean of those 30, which is all you would have in a real case. And it repeats that 3000 times. If a sample always told the truth, the 3000 means would all come out as 1. They don’t: the chart on the right shows how they are spread, some above and some below. Above the charts are the numbers that summarize it: mean of means, 0.995, and SE observed, 0.184 (the standard error: how far those means usually stray from their center, which is almost at the true 1; it is explained below, with a worked example).
Now press Compare with n×4: the tool repeats the experiment with samples of 120 and writes underneath “Before: n=30, SE 0.183 → Now: n=120, SE 0.091” (there the tool gives the theoretical SE, explained below; the observed one was 0.184). The SE drops to about half (the same simulator with 120, already run). With 300, to 0.057.

Finally, open the random walk, with 200 steps and seed 1. The green line goes up, goes down, goes up again and ends high, at +10. It looks like the chart of a stock on the market, with its good and bad streaks. Behind it, in gray, other walks with the same coin: each one ends somewhere different, some high and some low. Each of its 200 steps is a coin flip: +1 if it lands heads, −1 if it lands tails.
What just happened
The population is everything you are interested in (all the customers, all the questions that will be asked of a model, and so on) and the sample is the part of the total that you study. The mean of a sample resembles that of the population, but it is not the same, and it changes from one sample to another.
In AI this happens every time a model is evaluated. Its true score would be the one it would get on all the possible questions; the one you see comes from the few on which you test it.
How much it changes is measured with the standard error (SE): how far the mean of a sample usually strays from the true mean. It has a short formula, the one the tool calls “SE theoretical”: the spread of the population (σ, sigma) divided by the square root of the sample size (n).
In this population σ is 1, so with 30 values we get 1 / √30 ≈ 0.183; with 120, 1 / √120 ≈ 0.091; with 300, 0.058, within a thousandth of the 0.057 you saw. And note what the root says: to cut the error in half you need four times as much data, not twice.
Tip
To do it by hand
With the three samples of the first drawing, whose means came out 0.60, 0.88 and 1.33:
- The mean of each sample is the sum of its values divided by how many there are. With 10 values, the sum divided by 10.
- The mean of the means is the same with the means: (0.60 + 0.88 + 1.33) / 3 = 2.81 / 3 ≈ 0.94.
- The observed SE is how far those means usually stray from their own mean, their standard deviation. Subtract the mean of the means from each one, square it, take the mean of those squares and take the root: (0.60 − 0.94)² ≈ 0.116; (0.88 − 0.94)² ≈ 0.004; (1.33 − 0.94)² ≈ 0.152. Their mean is 0.272 / 3 ≈ 0.091, and the observed SE is .
- The theoretical SE needs no samples: σ / √n. With σ = 1 and n = 30, 1 / 5.48 ≈ 0.183.
The tool does the same with 3000 means instead of 3, and that is why its observed SE, 0.184, lands so close to the theoretical one.
The shape of the chart has its own story too. The exponential population is very skewed (many small values and a few very large ones), and yet the means are spread in the shape of a bell. This is the central limit theorem (CLT): the means of many samples tend toward that shape whatever the starting population (as long as its spread is finite). Its first version is the de Moivre–Laplace theorem, according to which the binomial can be approximated by a bell, and the modern form was not stated precisely until the 1920s (Central limit theorem, on Wikipedia).
That leaves the seed. A computer does not toss coins: it generates numbers that look random with a formula that starts from an initial value, the seed. With the same seed the same sequence always comes out (Pseudorandom number generator, on Wikipedia). That is why the “random” values the tool computes on your computer match the ones you see in this article, and why seeds are used when training models: they make it possible to repeat an experiment exactly. Try putting seed 2 in the CLT: the summaries come out the same up to the third decimal place, because with 3000 samples the differences cancel out. Each single sample varies a lot; the summary of 3000, very little.
The classic mistake
You might think that if a line rises and falls in streaks, something must be pushing it. The random walk has nothing behind it: each step is a coin flip, and it still draws “trends”. The tendency to see meaningful streaks in what is chance has a name, the clustering illusion, and famous examples: during the Second World War, Londoners built theories about where the German flying bombs were aimed, and an analysis from 1946 by R. D. Clarke found that the impacts fitted a random distribution and gave no support to the idea of clusters (“An application of the Poisson distribution”, Journal of the Institute of Actuaries, 1946).
In AI the same thing happens, in two ways. A model trained on little data can learn the noise as if it were a pattern (explained in Fitting a curve). And when comparing two models on a small sample of tests, a difference of a few points can be just chance (it has its own article: Is my improvement real?).
Try it yourself
Test yourself
In the CLT in Statistics, with the exponential population, set the sample size to 480. Before looking, predict with the formula above what the theoretical SE will come out as.
It will be ___.
The σ of this population is 1. And 480 is four times 120.
See the answer
Answer: 0.046 ± 0.002.
SE = σ/√n = 1/√480 ≈ 0.046. It is half of what it was with 120 (0.091), just as with 120 it was half of that with 30: to halve the error you have to quadruple the sample. The observed SE of the 3000 means, 0.045, stays close by.
In the random walk, raise p (step +1) to 0.55: now the coin lands heads 55% of the time, so there is a real upward trend. Run it several times with different seeds, looking only at the line, and then raise the steps to 2000.
Test yourself
When can you tell by eye a walk with p = 0.55 from one with p = 0.5?
- With 200 steps it is already clear: the line always goes up.
- Hardly with 200 steps; with 2000, yes.
- Never: with p = 0.55 the trend is too small.
See the answer
The answer is B.
With p = 0.55, each step goes up 0.1 on average, so the trend grows with the steps: 20 in 200 steps, 200 in 2000. The noise grows too, but more slowly, with the root: about 14 in 200 steps and about 45 in 2000. With 200, the trend is hidden by the noise; with 2000, the trend wins by a wide margin. It is the same root as in the SE.
Further reading
- On Jarroba, ¿Qué es el Machine Learning? (in Spanish), by Ricardo Moya, explains why it matters that the training data are a “sufficiently representative” sample.
- Clustering illusion, on Wikipedia: more examples of streaks that seem to mean something.
“A sample is not the whole truth: minimal statistics” by Ramón Invarato at jarroba.com, licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0. Registered at Safe Creative.

You may also like
Is my improvement real? When a difference is more than chance
Your change raises the metric: real improvement or chance? A/B testing, the p-value and the mistake of peeking at results too early. AI course, 1.4.
Bayes without formulas: why a positive does not mean what it seems
A test that is right 90% of the time and, if you test positive, only a 9% chance of being sick. Bayes by counting people, no formulas. AI course, 1.2.




Leave a comment