PROBABILITY & STATISTICS / 5. CONTINUOUS DISTRIBUTIONS

Continuous Distributions

Normal, Exponential, t, Chi-squared — the distributions you'll use daily


EXPLANATION

Continuous random variables take any value in a range. Described by PDF (Probability Density Function).

Key property: P(X=exactly x) = 0 for continuous RVs. You can only ask P(a ≤ X ≤ b) = ∫ f(x)dx from a to b.

Normal (Gaussian) N(μ, σ²):
• The most important distribution. Central Limit Theorem says sums of RVs converge to it
• Bell curve, symmetric around μ
• 68-95-99.7 rule: 1σ, 2σ, 3σ intervals

Standard Normal Z ~ N(0,1): Z = (X-μ)/σ  ← standardization

Exponential(λ): time between Poisson events. Memoryless property.
f(x) = λe^(-λx). E[X] = 1/λ

t-distribution: like Normal but heavier tails. Used when sample size is small or variance unknown. Parameterized by degrees of freedom ν. As ν→∞, t→Normal.

Chi-squared(k): sum of k squared standard normals. Used in hypothesis testing and confidence intervals for variance.

DIAGRAM

Normal N(μ=0, σ=1):
       ████
     ████████
   ████████████
  ─────┼─────── x
  -3σ  μ  +3σ

  68% within ±1σ
  95% within ±2σ
  99.7% within ±3σ

  t vs Normal (ν=5):
  t has heavier tails → more probability in extremes
  → more conservative → harder to reject H₀

  Chi-squared(k):
  k=1: exponential-like shape
  k=5: right-skewed
  k→∞: approaches Normal

CODE

PYTHON
1import numpy as np
2from scipy import stats
3import matplotlib.pyplot as plt
4
5# ── Normal distribution ───────────────────────────────────────────
6mu, sigma = 170, 10 # height in cm
7norm = stats.norm(mu, sigma)
8
9print("Normal(μ=170, σ=10) heights")
10print(f" P(X 180) = {norm.cdf(180):.4f}") # CDF
11print(f" P(160 X 180) = {norm.cdf(180)-norm.cdf(160):.4f}")
12print(f" P(X > 190) = {1-norm.cdf(190):.4f}")
13print(f" 95th percentile = {norm.ppf(0.95):.2f} cm") # inverse CDF
14
15# Standardization: Z = (X - μ) / σ
16x = 185
17z = (x - mu) / sigma
18print(f" x=185 z-score = {z:.2f}")
19print(f" P(X≤185) via z-table = {stats.norm.cdf(z):.4f}")
20
21# 68-95-99.7 rule
22for n_sigma, label in [(1, "68%"), (2, "95%"), (3, "99.7%")]:
23 prob = norm.cdf(mu + n_sigma*sigma) - norm.cdf(mu - n_sigma*sigma)
24 print(f" ±{n_sigma}σ contains {prob*100:.1f}% (rule says {label})")
25
26# ── t-distribution ────────────────────────────────────────────────
27print("\nt-distribution vs Normal (df=5)")
28df = 5
29t = stats.t(df)
30z_95 = stats.norm.ppf(0.975) # z for 95% CI
31t_95 = t.ppf(0.975) # t for 95% CI with df=5
32print(f" z(0.975) = {z_95:.4f}") # 1.96
33print(f" t(0.975, df=5) = {t_95:.4f}") # 2.57 — wider CI!
34
35# ── Exponential: time between events ─────────────────────────────
36lam = 2 # 2 events per hour → mean wait = 0.5 hours
37expon = stats.expon(scale=1/lam)
38print(f"\nExponential(λ=2)")
39print(f" Mean wait time = {expon.mean():.2f} hours")
40print(f" P(wait > 1 hr) = {1-expon.cdf(1):.4f}")
41# Memoryless: P(X>s+t | X>s) = P(X>t)
42print(f" Memoryless: P(X>1.5|X>0.5) = {(1-expon.cdf(1.5))/(1-expon.cdf(0.5)):.4f}")
43print(f" P(X>1.0) = {1-expon.cdf(1.0):.4f}") # same!
44
45# ── Chi-squared ───────────────────────────────────────────────────
46chi2_5 = stats.chi2(df=5)
47print(f"\nChi-squared(df=5)")
48print(f" Mean = {chi2_5.mean()}, Var = {chi2_5.var()}") # mean=df, var=2df
49print(f" 95th percentile = {chi2_5.ppf(0.95):.4f}") # critical value
← PREV4. Discrete DistributionsNEXT →6. Descriptive Statistics