1.3.11Probability & Statistics

Gaussian - Normal distribution properties

2,936 words13 min readdifficulty · medium6 backlinks

Core Definition

WHY this formula? Let's derive it from first principles.

Derivation from Maximum Entropy

Goal: Find the "most random" distribution with fixed mean μ\mu and variance σ2\sigma^2.

Step 1: Set up entropy maximization We want to maximize entropy H=f(x)lnf(x)dxH = -\int f(x) \ln f(x) dx subject to:

  • Normalization: f(x)dx=1\int f(x)dx = 1
  • Mean constraint: xf(x)dx=μ\int xf(x)dx = \mu
  • Variance constraint: (xμ)2f(x)dx=σ2\int (x-\mu)^2f(x)dx = \sigma^2

Why entropy? Maximizing entropy means assuming minimum information beyond our constraints—the distribution that makes fewest additional assumptions.

Step 2: Use Lagrange multipliers L=flnfdx+λ0(fdx1)+λ1(xfdxμ)+λ2((xμ)2fdxσ2)\mathcal{L} = -\int f \ln f dx + \lambda_0\left(\int f dx - 1\right) + \lambda_1\left(\int xf dx - \mu\right) + \lambda_2\left(\int (x-\mu)^2 f dx - \sigma^2\right)

Step 3: Take functional derivative with respect to ff δLδf=lnf1+λ0+λ1x+λ2(xμ)2=0\frac{\delta \mathcal{L}}{\delta f} = -\ln f - 1 + \lambda_0 + \lambda_1 x + \lambda_2(x-\mu)^2 = 0

Why this step? We're finding where the "slope" of entropy equals the "slope" of constraints—the balance point.

Step 4: Solve for f(x)f(x) lnf=1+λ0+λ1x+λ2(xμ)2\ln f = -1 + \lambda_0 + \lambda_1 x + \lambda_2(x-\mu)^2 f(x)=Aexp(λ1x+λ2(xμ)2)f(x) = A \exp(\lambda_1 x + \lambda_2(x-\mu)^2)

Step 5: Apply constraints The mean constraint forces λ1=0\lambda_1 = 0 (by symmetry around μ\mu). The variance constraint gives λ2=12σ2\lambda_2 = -\frac{1}{2\sigma^2}. Normalization gives A=1σ2πA = \frac{1}{\sigma\sqrt{2\pi}}.

Result: This is exactly our Gaussian formula.

Key Properties

WHY these numbers? They come from integrating the Gaussian PDF: P(μkσXμ+kσ)=μkσμ+kσ1σ2πexp((xμ)22σ2)dxP(\mu - k\sigma \leq X \leq \mu + k\sigma) = \int_{\mu-k\sigma}^{\mu+k\sigma} \frac{1}{\sigma\sqrt{2\pi}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) dx

Let z=xμσz = \frac{x-\mu}{\sigma} (standardize), then: =kk12πez2/2dz=erf(k2)= \int_{-k}^{k} \frac{1}{\sqrt{2\pi}} e^{-z^2/2} dz = \text{erf}\left(\frac{k}{\sqrt{2}}\right)

For k=1k=1: erf(1/2)0.683(1/\sqrt{2}) \approx 0.683

Property 1: Symmetry

The Gaussian is ==symmetric== around μ\mu: f(μ+a)=f(μa)f(\mu + a) = f(\mu - a) for all aa.

WHY? The exponent (xμ)2(x-\mu)^2 only depends on distance from μ\mu, not direction.

ML implication: Mean = Median = Mode. This makes μ\mu both the center and most likely value.

Property 2: Moments

Derivation: MX(t)=E[etX]=etx1σ2πexp((xμ)22σ2)dxM_X(t) = E[e^{tX}] = \int_{-\infty}^{\infty} e^{tx} \frac{1}{\sigma\sqrt{2\pi}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) dx

Step 1: Combine exponents =1σ2πexp(tx(xμ)22σ2)dx= \frac{1}{\sigma\sqrt{2\pi}} \int_{-\infty}^{\infty} \exp\left(tx - \frac{(x-\mu)^2}{2\sigma^2}\right) dx

Step 2: Complete the square tx(xμ)22σ2=12σ2[x22x(μ+σ2t)+μ2]tx - \frac{(x-\mu)^2}{2\sigma^2} = -\frac{1}{2\sigma^2}[x^2 - 2x(\mu + \sigma^2 t) + \mu^2] =12σ2[(xμσ2t)2σ4t22μσ2t]= -\frac{1}{2\sigma^2}[(x - \mu - \sigma^2 t)^2 - \sigma^4 t^2 - 2\mu\sigma^2 t] =(xμσ2t)22σ2+μt+σ2t22= -\frac{(x - \mu - \sigma^2 t)^2}{2\sigma^2} + \mu t + \frac{\sigma^2 t^2}{2}

Why complete the square? To get another Gaussian that integrates to 1.

Step 3: Factor out constants =eμt+σ2t2/21σ2πexp((xμσ2t)22σ2)dx= e^{\mu t + \sigma^2 t^2/2} \cdot \frac{1}{\sigma\sqrt{2\pi}} \int_{-\infty}^{\infty} \exp\left(-\frac{(x - \mu - \sigma^2 t)^2}{2\sigma^2}\right) dx

The integral is1 (Gaussian integral), giving our result.

From MGF, derive moments:

  • Mean: E[X]=M(0)=μE[X] = M'(0) = \mu
  • Variance: E[X2]E[X]2=M(0)M(0)2=σ2E[X^2] - E[X]^2 = M''(0) - M'(0)^2 = \sigma^2
  • Skewness: 0 (symmetric)
  • Excess kurtosis: 0(defines "normal" tail behavior)

Property 3: Linear Transformations

WHY? Use MGF: MY(t)=E[et(aX+b)]=ebtE[e(at)X]=ebtMX(at)M_Y(t) = E[e^{t(aX+b)}] = e^{bt} E[e^{(at)X}] = e^{bt} M_X(at) =ebtexp(μ(at)+σ2(at)22)=exp((aμ+b)t+(aσ)2t22)= e^{bt} \exp(\mu(at) + \frac{\sigma^2(at)^2}{2}) = \exp((a\mu+b)t + \frac{(a\sigma)^2 t^2}{2})

This is the MGF of N(aμ+b,a2σ2)\mathcal{N}(a\mu + b, a^2\sigma^2).

ML application: If features are Gaussian, standardizing Z=XμσZ = \frac{X-\mu}{\sigma} gives ZN(0,1)Z \sim \mathcal{N}(0,1).

Property 4: Sum of Independent Gaussians

Proof via MGF: MX+Y(t)=MX(t)MY(t)=exp(μ1t+σ12t22)exp(μ2t+σ22t22)M_{X+Y}(t) = M_X(t) M_Y(t) = \exp(\mu_1 t + \frac{\sigma_1^2 t^2}{2}) \cdot \exp(\mu_2 t + \frac{\sigma_2^2 t^2}{2}) =exp(μ1+μ2)t+(σ12+σ22)t22)= \exp(\mu_1+\mu_2)t + \frac{(\sigma_1^2+\sigma_2^2)t^2}{2})

Why independence matters? Without it, we'd have covariance terms: Var(X+Y)=σ12+σ22+2Cov(X,Y)\text{Var}(X+Y) = \sigma_1^2 + \sigma_2^2 + 2\text{Cov}(X,Y).

Central Limit Theorem connection: Sum of nn i.i.d. variables N(nμ,nσ2)\sim \mathcal{N}(n\mu, n\sigma^2). As nn \to \infty, the standardized sum converges to N(0,1)\mathcal{N}(0,1) even if original variables aren't Gaussian.

Property 5: Maximum Likelihood Estimation

Derivation:

Step 1: Write likelihood L(μ,σ2)=i=1n1σ2πexp((xiμ)22σ2)L(\mu, \sigma^2) = \prod_{i=1}^n \frac{1}{\sigma\sqrt{2\pi}} \exp\left(-\frac{(x_i-\mu)^2}{2\sigma^2}\right)

Step 2: Take log-likelihood (easier to maximize) (μ,σ2)=n2ln(2π)n2ln(σ2)12σ2i=1n(xiμ)2\ell(\mu, \sigma^2) = -\frac{n}{2}\ln(2\pi) - \frac{n}{2}\ln(\sigma^2) - \frac{1}{2\sigma^2}\sum_{i=1}^n(x_i-\mu)^2

Why log? Turns products into sums, and maximizing log is equivalent to maximizing the original (log is monotonic).

Step 3: Optimize for μ\mu μ=1σ2i=1n(xiμ)=0\frac{\partial \ell}{\partial \mu} = \frac{1}{\sigma^2}\sum_{i=1}^n(x_i-\mu) = 0 i=1nxi=nμμ^=1ni=1nxi\Rightarrow \sum_{i=1}^n x_i = n\mu \Rightarrow \hat{\mu} = \frac{1}{n}\sum_{i=1}^n x_i

Step 4: Optimize for σ2\sigma^2 σ2=n2σ2+12σ4i=1n(xiμ)2=0\frac{\partial \ell}{\partial \sigma^2} = -\frac{n}{2\sigma^2} + \frac{1}{2\sigma^4}\sum_{i=1}^n(x_i-\mu)^2 = 0 σ^2=1ni=1n(xiμ^)2\Rightarrow \hat{\sigma}^2 = \frac{1}{n}\sum_{i=1}^n(x_i-\hat{\mu})^2

Note: This is biased (divides by nn not n1n-1). The unbiased estimator uses n1n-1 (Bessel's correction).

Worked Examples

Common Mistakes

Recall Explain to a 12-year-old

Imagine you're throwing darts at a target. If you're pretty good, most darts land near the center, but some miss by a little, and very few miss by a lot. If we drew a graph of how far each dart is from the center, we'd get a bell-shaped curve—that's the Gaussian distribution!

The "mean" (μ\mu) is where you're aiming (the bullseye). The "standard deviation" (σ\sigma) is how consistent you are. A small σ\sigma means you're super accurate (darts cluster tight), while a big σ\sigma means your throws are all over the place. The cool part: about 68% of your darts land within one "standard deviation" of the bullseye. About 95% land within two standard deviations. And99.7% land within three. So if someone says their dart landed "3 standard deviations away," that's like saying "whoa, that's a really weird throw—only happens0.3% of the time!"

Why is this everywhere in AI? Because when lots of random things add up (like tiny errors in measurements, or genetic factors affecting height, or pixel noise in images), the total follows this bell curve pattern. It's nature's way of organizing randomness.

Connections

This concept connects to:

#flashcards/ai-ml

What is the PDF of a Gaussian distribution and what do its parameters represent? :: 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). Parameter μ\mu is the mean (center location), and σ2\sigma^2 is the variance (spread). Standard deviation σ\sigma controls width.

State the 68-95-99.7 empirical rule for Gaussians.
68% of data falls within μ±σ\mu \pm \sigma, 95% within μ±2σ\mu \pm 2\sigma, and 99.7% within μ±3σ\mu \pm 3\sigma. These come from integrating the Gaussian PDF over symmetric intervals.
If XN(μ,σ2)X \sim \mathcal{N}(\mu, \sigma^2), what is the distribution of Y=aX+bY = aX + b?
YN(aμ+b,a2σ2)Y \sim \mathcal{N}(a\mu + b, a^2\sigma^2). The mean scales and shifts by aa and bb, while variance scales by a2a^2 (not aa, because variance has squared units).
If XN(μ1,σ12)X \sim \mathcal{N}(\mu_1, \sigma_1^2) and YN(μ2,σ22)Y \sim \mathcal{N}(\mu_2, \sigma_2^2) are independent, what is X+YX + Y?
X+YN(μ1+μ2,σ12+σ22)X + Y \sim \mathcal{N}(\mu_1 + \mu_2, \sigma_1^2 + \sigma_2^2). Means add, variances add (not standard deviations). This requires independence.
What are the MLE estimators for μ\mu and σ2\sigma^2 from data x1,,xnx_1, \ldots, x_n?
μ^=1nxi\hat{\mu} = \frac{1}{n}\sum x_i (sample mean) and σ^2=1n(xiμ^)2\hat{\sigma}^2 = \frac{1}{n}\sum(x_i - \hat{\mu})^2 (divides by nn, which is biased). The unbiased estimator divides by n1n-1.
What is the moment generating function of N(μ,σ2)\mathcal{N}(\mu, \sigma^2)?
MX(t)=exp(μt+σ2t22)M_X(t) = \exp\left(\mu t + \frac{\sigma^2 t^2}{2}\right). This uniquely characterizes the Gaussian and can be used to derive all moments.
Why is the Gaussian distribution derived from maximum entropy?
It's the distribution with highest entropy (most uncertainty) given fixed mean μ\mu and variance σ2\sigma^2. This means it makes the fewest assumptions beyond these constraints—it's the "least informative" distribution consistent with what we know.
What happens to standard deviation when you average nn independent Gaussian measurements?
It decreases by n\sqrt{n}. If each measurement has std dev σ\sigma, the average has std dev σn\frac{\sigma}{\sqrt{n}}. This is why more samples give more precision, but with diminishing returns.
Why do we standardize with Z=XμσZ = \frac{X-\mu}{\sigma} when working with Gaussians?
To convert any N(μ,σ2)\mathcal{N}(\mu, \sigma^2) to the standard normal N(0,1)\mathcal{N}(0, 1), which has tabulated values. Standardization is a linear transformation: ZN(0,1)Z \sim \mathcal{N}(0, 1).
What's the key difference between N(μ,σ2)\mathcal{N}(\mu, \sigma^2) and N(μ,σ)\mathcal{N}(\mu, \sigma) notation?
The second parameter: N(μ,σ2)\mathcal{N}(\mu, \sigma^2) uses variance (squared units), while N(μ,σ)\mathcal{N}(\mu, \sigma) would use std dev (original units). Standard notation uses variance. Always check which convention is being used.

Concept Map

explains why

derives

used in

constrain

defines

has parameter

has parameter

integrated gives

transforms integral to

computes

exhibits

Central Limit Theorem

Gaussian Distribution

Maximum Entropy Principle

Gaussian PDF formula

Lagrange Multipliers

Fixed Mean and Variance

Mean mu - center

Variance sigma squared - spread

68-95-99.7 Rule

Standardize z-score

Error function erf

Symmetry about mu

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, is Gaussian ya Normal distribution ki sabse badi baat yeh hai ki yeh nature aur AI dono mein baar-baar dikhta hai, aur iske peeche jo main reason hai woh hai Central Limit Theorem. Iska matlab simple hai — jab bahut saare independent random effects ek saath add hote hain, toh unka total hamesha bell curve (ghanti jaisi shape) banata hai, chahe individual effects kaise bhi ho. Jaise human height ko lo — isme genes, nutrition, environment sab milke ek smooth bell curve bana dete hain. ML mein hum isliye maan lete hain ki noise ya errors Gaussian hote hain, kyunki bahut saari chhoti-chhoti galtiyan milke exactly aisa hi pattern banati hain.

Ab formula ki baat karein toh usme do main cheezein hain — mean (μ) jo batata hai peak kahan hai yaani center kahan hai, aur variance (σ²) ya standard deviation jo batata hai spread kitna hai yaani curve kitni chaudi hai. Ek khoobsurat baat yeh hai ki yeh distribution maximum entropy se derive hota hai — matlab jab humein sirf mean aur variance pata ho aur baaki koi assumption na banani ho, toh sabse "random" ya sabse honest distribution yahi Gaussian nikalta hai. Yeh isliye important hai kyunki iska matlab hai ki Gaussian koi random choice nahi, balki mathematically sabse natural choice hai jab humein zyada information nahi hoti.

Practical use ke liye 68-95-99.7 rule yaad rakho — data ka 68% ek σ ke andar, 95% do σ ke andar, aur 99.7% teen σ ke andar aata hai. Yeh rule real life mein bahut kaam aata hai, jaise outliers detect karne mein ya yeh samajhne mein ki koi value normal hai ya unusual. Aur kyunki curve symmetric hota hai, isme mean, median aur mode teenon ek hi jagah hote hain — isse μ automatically center bhi ban jaata hai aur most likely value bhi. Yeh saari properties milke Gaussian ko machine learning, statistics aur data science ka backbone bana deti hain, isliye ise achhe se samajhna zaroori hai.

Go deeper — visual, from zero

Test yourself — Probability & Statistics

Connections