Normal Distribution — The Bell Curve
The most important shape in all of statistics — data that clusters around a centre and fades at the edges.
A normal distribution is a bell-shaped curve where most values cluster near the mean. It is defined by mean and standard deviation.
EXERCISE
1The Normal Distribution — Nature's Favourite Shape
From human heights to exam scores to measurement errors — an astonishing number of real-world phenomena follow the bell curve.
The bell curve is like a crowd gathering around a street performer. Most people stand close to the centre (the mean), fewer stand further away, and hardly anyone stands at the far edges. This shape appears everywhere in nature.
Generating a normal distribution:
import numpy
import matplotlib.pyplot as plt
# mean=5.0, std_dev=1.0, 100,000 data points
x = numpy.random.normal(5.0, 1.0, 100000)
plt.hist(x, 100)
plt.title("Normal Distribution (mean=5, std=1)")
plt.show()
# Output: A bell-shaped curve centred at 5.0
The two numbers that define it:
import numpy
data = numpy.random.normal(5.0, 1.0, 100000)
print(f"Mean: {round(numpy.mean(data), 2)}")
# Output: Mean: ~5.00
print(f"Std Dev: {round(numpy.std(data), 2)}")
# Output: Std Dev: ~1.00
# The mean sets the CENTRE
# The std dev sets the WIDTH
Pro Tip: The normal distribution is completely defined by just two numbers: mean (where the centre is) and standard deviation (how wide it is). Change the mean and the bell slides left or right. Change the std dev and the bell gets wider or narrower. That is it — two knobs control the entire shape.
EXERCISE
2Reading and Interpreting a Bell Curve
A bell curve is not just a pretty picture — every part of it tells you something specific about your data.
Reading a bell curve is like reading a heat map of popularity. The peak is where most of your data lives. The tails show the rare extremes. The width tells you how spread out your data is.
Changing the mean shifts the curve:
import numpy
# Same spread (std=1.0), different centres
group_a = numpy.random.normal(3.0, 1.0, 10000)
group_b = numpy.random.normal(7.0, 1.0, 10000)
print(f"Group A mean: {round(numpy.mean(group_a), 2)}")
# Output: Group A mean: ~3.00
print(f"Group B mean: {round(numpy.mean(group_b), 2)}")
# Output: Group B mean: ~7.00
# Same shape, but Group B is shifted 4 units right
Changing the std dev changes the width:
import numpy
# Same centre (mean=5.0), different spreads
narrow = numpy.random.normal(5.0, 0.5, 10000)
wide = numpy.random.normal(5.0, 3.0, 10000)
print(f"Narrow std: {round(numpy.std(narrow), 2)}")
# Output: Narrow std: ~0.50
print(f"Wide std: {round(numpy.std(wide), 2)}")
# Output: Wide std: ~3.00
# Narrow: most values between 4.0-6.0
# Wide: values spread from -4.0 to 14.0
The anatomy of a bell curve:
| Region | Covers | Meaning |
|---|---|---|
| Mean ± 1σ | ~68% of data | Common values |
| Mean ± 2σ | ~95% of data | Almost everything |
| Mean ± 3σ | ~99.7% of data | Virtually everything |
| Beyond 3σ | ~0.3% | True outliers |
Pro Tip: Many ML algorithms secretly assume your data is normally distributed — or at least close. When it is not, transforming your data to look more "bell-shaped" (using log transforms, Box-Cox, etc.) can dramatically improve model performance.
EXERCISE
3Why the Normal Distribution Matters for ML
The bell curve is not just a statistics lesson — it is baked into the assumptions of half the algorithms you will ever use.
The normal distribution is to ML what gravity is to engineering — you can ignore it, but your results will crash and burn.
Why it matters — three practical reasons:
1. Feature scaling assumes normality:
import numpy
from sklearn.preprocessing import StandardScaler
data = numpy.array([[1000], [1200], [900], [1100], [1050]])
scaler = StandardScaler()
scaled = scaler.fit_transform(data)
print(scaled.flatten().round(2))
# Output: [-0.42 1.47 -1.37 0.53 0.05]
# StandardScaler transforms to mean=0, std=1
# This works BEST when data is already roughly normal
2. Many algorithms assume normal errors:
import numpy
# Linear regression assumes residuals (errors) are normal
predictions = numpy.array([100, 105, 95, 110, 90])
actual = numpy.array([102, 103, 98, 108, 93])
residuals = actual - predictions
print(f"Mean residual: {numpy.mean(residuals)}")
# Output: Mean residual: 0.4
print(f"Std of residuals: {round(numpy.std(residuals), 2)}")
# Output: Std of residuals: 2.87
# If residuals are roughly normal → model assumptions hold
3. Central Limit Theorem — the great equaliser:
import numpy
# Even with NON-normal data, sample means become normal
weird_data = numpy.random.exponential(2.0, 100000)
# Take 1000 samples of size 30 and compute their means
sample_means = [numpy.mean(numpy.random.choice(weird_data, 30)) for _ in range(1000)]
print(f"Mean of sample means: {round(numpy.mean(sample_means), 2)}")
# Output: Mean of sample means: ~2.00
# The sample means are normally distributed!
Pro Tip: The Central Limit Theorem says that if you take enough random samples from ANY distribution and average them, those averages will be normally distributed. This is why the normal distribution keeps appearing in ML — even when your underlying data is not normal, the statistics you calculate from it often are.
