Probability and Statistics
Descriptive statistics and the Gaussian
Summarizing data: mean, variance, the bell curve
You cannot look at a million numbers at once, so you summarise them. Where is the cloud centred? How wide is it? What shape does it take? Three answers - the mean (centre), the standard deviation (width), and the Gaussian (the bell shape a great many clouds fall into) - carry almost all the everyday statistics that machine learning leans on. Get these into your fingers and terms like "normalize the features," "unit variance," and "standard normal" stop being jargon and start being pictures.
The one-line idea
Mean: the balance point
The mean (or average) of values is their sum divided by how many there are:
The physical picture is a seesaw. Place each data point as an equal weight along a ruler; the mean is the single spot where the ruler balances. Slide one point far to the right and the balance point drifts right to compensate - which is exactly why the mean is sensitive to outliers. It is the centre of mass of the data.
Spread: variance and standard deviation
Two clouds can share a mean yet look nothing alike - one tight, one sprawling. To capture width, measure how far each point sits from the mean, . Those gaps are positive and negative and would cancel to zero if we just added them, so we square them first, then average. That average squared gap is the variance:
Squaring fixed the sign problem but left the units wrong - if is in metres, is in metres squared. So take the square root to get back into the data's own units. That is the standard deviation , the number you actually quote as "the spread":
The bell curve and the 68-95-99.7 rule
Astonishingly often, when many small independent effects add up, the resulting spread takes one particular smooth shape: the normal distribution, or Gaussian. It is a symmetric bell, tallest at the mean and thinning out on both sides. It is written - fully pinned down by just the centre and the width - and its height at a value is
Because the bell is fixed once you know and , distances are naturally measured in standard deviations. That gives the famous 68-95-99.7 rule: about 68% of a Gaussian's values fall within of the mean, about 95% within , and about 99.7% within . Land more than three standard deviations out and you are in genuinely rare territory.
Drag the points below. Watch the mean line, the shaded band, the variance readout, and the fitted bell all respond to the cloud you build - then hit normalize to standardise it.
Spread the dots apart and the band widens, the variance grows, and the bell flattens. Bunch them up and it all tightens. Normalize slides the whole cloud onto the origin and squeezes it to unit width - the same numbers, measured with a common ruler.
The z-score: one common ruler
To compare quantities on wildly different scales - a person's height in centimetres and their income in dollars - recast each value as "how many standard deviations from its own mean" it sits. That is the z-score:
Subtracting recenters the cloud onto ; dividing by rescales it to a spread of exactly . The transformed data always has mean and standard deviation - a standard normal if the original was Gaussian. That is precisely the motion the normalize toggle animates above.
Shape and scale are separate knobs
The four numbers in NumPy:
import numpy as np
x = np.array([4, 6, 7, 8, 9, 10, 11, 12, 14])
mu = x.mean() # balance point -> 9.0
var = ((x - mu) ** 2).mean() # mean squared distance -> 8.67
sigma = np.sqrt(var) # spread, in x's own units -> 2.94
z = (x - mu) / sigma # z-scores: recenter, then rescale
# z.mean() -> 0.0 z.std() -> 1.0Check yourself
What does the standard deviation of a dataset measure?
About what fraction of a normal distribution lies within one sigma of the mean?
Recall the formulas for the mean, variance, and standard deviation - and what a z-score does to a value.
These four computations are the foundation of all normalisation in ML. Try to state it, then check.
Lock it in
- The mean is the balance point - the centre of mass of the data cloud.
- Variance squares the gaps from the mean; standard deviation takes the root to get back to original units.
- The Gaussian is the default bell shape: 68% within , 95% within , 99.7% within .
- The z-score recenters to 0 and rescales to 1 - standardising features without destroying their shape.
Primary source
Ask your teacher