The Normal Distribution
Intuition
Heights, measurement errors and averages of many small effects pile up in a symmetric bell shape. The normal distribution describes that bell: is its centre and 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)
Cumulative probability (cdf), using the error function math.erf:
- . A single point has probability 0; is a density, not a probability, and can exceed 1 when is small.
- Standardising with (ST-05) turns any normal into .
- 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 , is close to , and — the continuity correction accounts for replacing bars at integers with a smooth curve.
Worked example
: ; .
Common mistakes
- Passing the variance where the standard deviation is expected.
- Treating as .
- Forgetting the 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
- OpenIntro Statistics — OpenIntro (
S011) - statistics — Mathematical statistics functions — Python Software Foundation (
S003) - math — Mathematical functions — Python Software Foundation (
S050)