AI Wiki中文/EN

Gaussian distributions

高斯分布

Understand the roles of mean, standard deviation, and covariance, compute interval probabilities, and identify when a bell-shaped model is unsuitable.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

A center and a scale do different jobs

Suppose a teaching model assigns a Gaussian distribution to a machine’s position error. Mean μ\mu shifts the center; standard deviation σ\sigma sets the spread. Moving the mean does not make the error less variable. Shrinking the spread raises the density near the center while preserving total area 1.

For numerical practice, use a variable with μ=10\mu=10 and σ=2\sigma=2. Values 8 and 12 lie one standard deviation below and above the center. Their probability depends on the area between them, not on the density at either endpoint. The Gaussian assumption is part of the model; it does not follow from knowing only a mean and variance.

Standardize before comparing intervals

The univariate Gaussian, also called the normal distribution, has density:

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

Its notation X∼N(μ,σ2)X\sim\mathcal N(\mu,\sigma^2) uses variance as the second parameter, while many sampling APIs accept standard deviation. Confusing 2 with 222^2 changes the model. The normalizing factor compensates for widening the curve. Substitution z=(x−μ)/σz=(x-\mu)/\sigma gives dx=σ dzdx=\sigma\,dz, leaving the standard-normal density and its unit integral. Deep Learning, Section 3.9.3

Write Φ\Phi for the standard-normal CDF. Then:

Z=X−μσ∼N(0,1),P(a<X≤b)=Φ ⁣(b−μσ)−Φ ⁣(a−μσ).Z=\frac{X-\mu}{\sigma}\sim\mathcal N(0,1),\qquad P(a<X\le b)=\Phi\!\left(\frac{b-\mu}{\sigma}\right)-\Phi\!\left(\frac{a-\mu}{\sigma}\right).

The example assigns approximately 0.682689 to [8,12][8,12] and 0.954500 to [6,14][6,14]. These are consequences of the Gaussian model, not distribution-free promises about every dataset’s one- and two-standard-deviation intervals.

For dd dimensions, replace the scalar mean and variance with a vector μ\mu and covariance matrix Σ\Sigma. If Σ\Sigma is symmetric positive definite, meaning v⊤Σv>0v^\top\Sigma v>0 for every nonzero vv, the full-dimensional density is:

p(x)=exp⁡ ⁣[−12(x−μ)⊤Σ−1(x−μ)](2π)d/2det⁡Σ.p(x)=\frac{\exp\!\left[-\tfrac12(x-\mu)^\top\Sigma^{-1}(x-\mu)\right]}{(2\pi)^{d/2}\sqrt{\det\Sigma}}.

The quadratic form measures distance using the covariance geometry. Off-diagonal entries encode covariance. A diagonal covariance makes components independent within a jointly Gaussian distribution; this conclusion is not valid for arbitrary uncorrelated variables. Singular covariance instead describes a degenerate Gaussian on a lower-dimensional set, and the ordinary full-dimensional density above is unavailable. MML, Section 6.5

Compute density and probability separately

This complete Python program uses the standard library’s complementary error function for the CDF. It returns log density before exponentiating, which helps keep very small likelihoods representable during computation.

import math

def standardized(x, mu, sigma):
    if not all(math.isfinite(v) for v in [x,mu,sigma]) or sigma <= 0:
        raise ValueError("finite inputs and positive standard deviation required")
    return (x-mu)/sigma

def normal_logpdf(x, mu=0.0, sigma=1.0):
    z = standardized(x, mu, sigma)
    return -0.5*z*z-math.log(sigma)-0.5*math.log(2*math.pi)

def normal_cdf(x, mu=0.0, sigma=1.0):
    z = standardized(x, mu, sigma)
    return 0.5*math.erfc(-z/math.sqrt(2))

def interval(a, b, mu=0.0, sigma=1.0):
    if a > b:
        raise ValueError("interval endpoints must be ordered")
    return normal_cdf(b,mu,sigma)-normal_cdf(a,mu,sigma)

assert normal_cdf(10,10,2) == .5
assert math.isclose(interval(8,12,10,2), .6826894921370859)
assert math.isclose(interval(6,14,10,2), .9544997361036416)
assert math.isclose(math.exp(normal_logpdf(10,10,2)), 1/(2*math.sqrt(2*math.pi)))
assert interval(2,2) == 0
assert normal_logpdf(40) < -800
try:
    normal_cdf(0,0,0)
except ValueError:
    pass
else:
    raise AssertionError("zero standard deviation must be rejected")

Each scalar call uses a fixed number of elementary or special-function evaluations. For dense dd-dimensional data, a Cholesky factorization of covariance costs O(d3)O(d^3); once available, a solve-based log-density evaluation typically costs O(d2)O(d^2). Computing an explicit inverse for each point is unnecessary.

Bell curves do not explain every uncertainty

Gaussian density is positive across the real line. It can assign probability to impossible negative durations or capacities. Truncation, transformations, or another distribution may better reflect support constraints. A mixture of distinct operating modes can also be poorly summarized by one Gaussian.

Affine transformations preserve Gaussianity: if XX is Gaussian, AX+bAX+b has mean Aμ+bA\mu+b and covariance AΣA⊤A\Sigma A^\top, possibly singular. Nonlinear transformations generally do not. Squaring a standard normal creates a nonnegative variable, not another Gaussian.

The classical central limit theorem concerns appropriately standardized sums of i.i.d. variables with finite nonzero variance as the number of terms grows. It does not say the raw observations are Gaussian, that a fixed small sample is sufficient, or that arbitrary dependent or heavy-tailed sums obey the same conclusion. Use diagnostics and a model-specific argument.

In far tails, subtracting two nearly equal CDF values can lose precision. Production statistical libraries provide survival functions and stable log-probability routines. The program here illustrates central probabilities and moderate inputs, not every numerical extreme.

Check what the parameters mean

  1. For X∼N(10,4)X\sim\mathcal N(10,4), what is its standard deviation? Answer: 2, not 4.
  2. What is P(X≤10)P(X\le10)? Answer: 1/21/2, by symmetry and continuity.
  3. If Y=3X−1Y=3X-1, what are its mean and variance? Answer: 29 and 36.
  4. Do two Gaussian-looking marginal histograms prove a jointly Gaussian distribution? Answer: no. The joint dependence structure needs examination too.

A useful model, with testable consequences

Gaussian assumptions make conditioning, marginalization, and affine propagation tractable. They appear in linear regression noise models, Kalman filters, Gaussian processes, and diffusion-model perturbations. The role differs in each case: observational noise is a data assumption, while intentionally injected Gaussian noise is a design choice. State which role the distribution plays before judging whether it fits reality.

Make a prediction, then check

X follows N(10,4). How many standard deviations above the mean is 12?

Choose one answer

Learning objectives

  • Calculate standardized values, density, and interval probabilities from a mean and standard deviation.
  • Explain covariance, degenerate Gaussians, and the assumptions limiting central-limit arguments.

Prerequisites & connections

Explore related knowledge →

References

  1. Mathematics for Machine Learning — mathematical foundations (2024-01-15 draft)
    Marc Peter Deisenroth; A. Aldo Faisal; Cheng Soon Ong · 2020
  2. Deep Learning — Chapter 3: Probability and Information Theory
    Ian Goodfellow; Yoshua Bengio; Aaron Courville · 2016

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-05 · Codex technical check: cited-source comparison, re-derivation and recalculation, bilingual argument comparison, and executed Python assertions; no independent human peer review.

  • Checked standardization, variance versus standard deviation, interval probabilities 0.682689/0.954500, and affine mean 29/variance 36.
  • Compared Simpson integration with CDF interval probabilities for nine mean/standard-deviation pairs; checked positive-definite versus singular covariance, classical CLT assumptions, and tail cancellation limits.
  • Compared arguments, modeling assumptions, numbers, and exercise answers across languages; structural checks separately compare display formulas, code, references, and main sections. No independent human peer review.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.