TExcelTAD
Home › Statistics › Normal Distribution

Normal Distribution

The normal distribution (also called the Gaussian distribution or bell curve) is the most important probability distribution in statistics. Many natural measurements are approximately normal (heights, measurement errors, blood pressure), and, thanks to the Central Limit Theorem, averages of almost any kind of data are approximately normal too. That is why most of inferential statistics is built on it.

Shape and parameters

A normal distribution is completely described by two parameters:

  • the mean μ, which sets the centre (the peak), and
  • the standard deviation σ, which sets the width.

It is symmetric around μ, so mean, median and mode are equal. The tails extend forever in both directions but become very thin very quickly. Its probability density function is

text
f(x) = 1 / (σ √(2π)) × e^(−(x − μ)² / (2σ²))

You never need to evaluate it by hand. SciPy's stats.norm does it for you. The plot below shows how μ shifts the curve and σ stretches it:

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

x = np.linspace(-10, 14, 400)
fig, ax = plt.subplots(figsize=(6.5, 3.5))
for mu, sigma, color in [(0, 1, "#2a78d6"), (0, 3, "#eb6834"), (5, 1.5, "#1baf7a")]:
    ax.plot(x, stats.norm.pdf(x, mu, sigma), color=color, linewidth=2, label=f"μ={mu}, σ={sigma}")
ax.legend(frameon=False)
ax.set_ylabel("density")
plt.tight_layout()
plt.show()
print("Plotted three normal curves; the peak height at the mean is 1/(σ√(2π)):")
for sigma in [1, 3, 1.5]:
    print(f"  σ={sigma}: {stats.norm.pdf(0, 0, sigma):.4f}")
Plotted three normal curves; the peak height at the mean is 1/(σ√(2π)):
  σ=1: 0.3989
  σ=3: 0.1330
  σ=1.5: 0.2660

The total area under every curve is 1, so a wider curve must be flatter.

Probabilities are areas

For a continuous distribution, the probability that a value falls in an interval is the area under the curve over that interval. The cumulative distribution function (CDF) gives the area to the left of a value: P(X ≤ x).

Suppose the lifetime of a brand of LED bulbs is normal with μ = 20,000 hours and σ = 1,500 hours:

python · try it yourself
from scipy import stats

life = stats.norm(loc=20_000, scale=1_500)

print(f"P(X < 18,000)          = {life.cdf(18_000):.4f}")
print(f"P(X > 23,000)          = {life.sf(23_000):.4f}")          # sf = 1 - cdf
print(f"P(19,000 < X < 22,000) = {life.cdf(22_000) - life.cdf(19_000):.4f}")
print(f"10% of bulbs fail before {life.ppf(0.10):,.0f} hours")
P(X < 18,000)          = 0.0912
P(X > 23,000)          = 0.0228
P(19,000 < X < 22,000) = 0.6563
10% of bulbs fail before 18,078 hours
  • cdf(x): area to the left of x.
  • sf(x): the survival function, area to the right (1 − cdf), more precise in the far tail.
  • ppf(q): the inverse of the CDF ("percent point function"). It returns the value with probability q to its left. Use it to find percentiles.

Python's standard library has the same tools in statistics.NormalDist:

python · try it yourself
from statistics import NormalDist

life = NormalDist(mu=20_000, sigma=1_500)
print(round(life.cdf(18_000), 4))
print(round(life.inv_cdf(0.10)))
print(round(life.cdf(22_000) - life.cdf(19_000), 4))
0.0912
18078
0.6563

The 68–95–99.7 rule, exactly

The empirical rule from Standard Deviation comes straight from the normal curve:

python · try it yourself
from scipy import stats

for k in [1, 2, 3]:
    inside = stats.norm.cdf(k) - stats.norm.cdf(-k)
    print(f"within ±{k}σ: {inside:.4%}")
print(f"±1.96σ covers {stats.norm.cdf(1.96) - stats.norm.cdf(-1.96):.4f}")
within ±1σ: 68.2689%
within ±2σ: 95.4500%
within ±3σ: 99.7300%
±1.96σ covers 0.9500

The last line explains a number you will see constantly: 95% of a normal distribution lies within 1.96 standard deviations of the mean.

Does my data look normal?

Real data is never perfectly normal. Two quick checks are a histogram with the fitted curve on top and a Q–Q plot, which plots the sorted data against the values a normal distribution would predict. If the data is normal, the points follow a straight line:

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

rng = np.random.default_rng(14)
weights = rng.normal(3.4, 0.45, size=300)        # newborn weights in kg
mu, sigma = weights.mean(), weights.std(ddof=1)

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 3.5))
ax1.hist(weights, bins=20, density=True, color="#86b6ef", edgecolor="white")
x = np.linspace(weights.min(), weights.max(), 200)
ax1.plot(x, stats.norm.pdf(x, mu, sigma), color="#2a78d6", linewidth=2)
ax1.set_title("histogram + fitted normal")
stats.probplot(weights, dist="norm", plot=ax2)
ax2.set_title("Q-Q plot")
fig.tight_layout()
plt.show()
print(f"fitted μ = {mu:.3f} kg, σ = {sigma:.3f} kg")
fitted μ = 3.436 kg, σ = 0.436 kg

The histogram follows the curve and the Q–Q points hug the line: the normal model fits well. A curved Q–Q pattern would indicate skewness, and S-shapes would indicate tails that are too heavy or too light.

Test yourself

Which two parameters completely describe a normal distribution?

  1. Median and range
  2. Mean μ and standard deviation σ
  3. Mode and IQR
  4. Minimum and maximum

What does stats.norm(50, 10).ppf(0.9) return?

  1. The probability of a value below 0.9
  2. The value below which 90% of the distribution lies
  3. The density at 0.9
  4. The probability of a value above 90

IQ scores are normal with μ = 100, σ = 15. About what share of people score above 130?

  1. 2.5%
  2. 5%
  3. 16%
  4. 0.15%