The Normal Distribution

Intuition

Heights, measurement errors and averages of many small effects pile up in a symmetric bell shape. The normal distribution N(μ,σ2)\mathcal N(\mu, \sigma^2) describes that bell: μ\mu is its centre and σ\sigma its width. Because it is continuous, we ask for the probability of an interval, which is the area under the curve.

Precise explanation

Density (pdf)

f(x)=1σ2πexp⁡ ⁣(−(x−μ)22σ2).f(x) = \frac{1}{\sigma\sqrt{2\pi}}\exp\!\left(-\frac{(x-\mu)^2}{2\sigma^2}\right).

Cumulative probability (cdf), using the error function math.erf:

F(x)=P(X≤x)=12[1+erf⁡ ⁣(x−μσ2)].F(x) = P(X \le x) = \tfrac12\left[1 + \operatorname{erf}\!\left(\frac{x-\mu}{\sigma\sqrt2}\right)\right].
  • P(a≤X≤b)=F(b)−F(a)P(a \le X \le b) = F(b) - F(a). A single point has probability 0; f(x)f(x) is a density, not a probability, and can exceed 1 when σ\sigma is small.
  • Standardising with z=(x−μ)/σz = (x - \mu)/\sigma (ST-05) turns any normal into N(0,1)\mathcal N(0, 1).
  • 68–95–99.7 rule: about 68.27%, 95.45% and 99.73% of the mass lies within 1, 2 and 3 standard deviations of the mean.
  • Normal approximation to the binomial (ST-08): for large nn, X∼Bin(n,p)X \sim \text{Bin}(n, p) is close to N(np, np(1−p))\mathcal N(np,\, np(1-p)), and P(X≤k)≈F(k+0.5)P(X \le k) \approx F(k + 0.5) — the +0.5+0.5 continuity correction accounts for replacing bars at integers with a smooth curve.

Worked example

N(170,102)\mathcal N(170, 10^2): P(X≤180)=F(180)=12[1+erf⁡(1/2)]≈0.8413P(X \le 180) = F(180) = \frac12[1 + \operatorname{erf}(1/\sqrt2)] \approx 0.8413; P(160≤X≤180)≈0.8413−0.1587=0.6827P(160 \le X \le 180) \approx 0.8413 - 0.1587 = 0.6827.

Common mistakes

  • Passing the variance where the standard deviation is expected.
  • Treating f(x)f(x) as P(X=x)P(X = x).
  • Forgetting the 2\sqrt2 inside the erf.

Why this matters

Confidence intervals (ST-12), the t-test (ST-18), weight initialisation and Gaussian noise for privacy all use the normal distribution.

Library implementation

statistics.NormalDist(mu, sigma) provides .pdf(x), .cdf(x) and .inv_cdf(p) (the quantile function you will use for confidence intervals), plus arithmetic on independent normal variables. scipy.stats.norm offers the same functions vectorised over arrays. The tests compare your functions with NormalDist, and with SciPy if it is installed.

References