BRAGA

02 Writing02-02 Notes02-02-394

Variance

Published 16 Apr 20263 min read
Contents
  1. 01Deep Breakdown
  2. 02Flowchart
  3. 03Real-world use
  4. 04The formula, piece by piece
  5. 05The formula in words
  6. 06Critical Concepts
  7. 07Step-by-step calculation (tiny example)
  8. 08Code examples
Var(X)=σ2Var(X) = \sigma^2
(1)

Deep Breakdown

What it tells me (Situation Awareness): For the Normal distribution N(μ,σ2)N(\mu, \sigma^2), the variance is the parameter σ2\sigma^2 by definition. It controls the width of the bell curve: small σ2\sigma^2 = narrow, tall peak; large σ2\sigma^2 = wide, flat curve. Estimating σ2\sigma^2 from data is essential for confidence intervals, significance tests, and feature normalization.

Flowchart

Normal(μ, σ²)Var(X) = σ²(scaleparameter)Small σ²:narrow,concentratedLarge σ²: wide,dispersedσ = √σ² controlsCI width andz-scoredenominator

Real-world use

Where it is used

Confidence interval construction (±zσ\pm z \sigma), power analysis (effect size = Δμ/σ\Delta\mu/\sigma), regularization scale selection, and feature normalization (StandardScaler divides by σ^\hat{\sigma}).

Problem it solves

Characterizes the dispersion of a Normal distribution — needed for all probability queries and parameter estimation.

How it solves the problem

σ2\sigma^2 is the second free parameter of the Normal distribution. It enters every probability computation through the standardized z-score (x−μ)/σ(x - \mu)/\sigma.

Example in a business

Sample size calculation: to detect a 5% lift in conversion (from 10% to 10.5%) at 80% power with α=0.05\alpha=0.05, the required nn depends on σ2=p(1−p)\sigma^2 = p(1-p) of the Bernoulli conversion model.

The formula, piece by piece

Var(X)=σ2Var(X) = \sigma^2 for X∼N(μ,σ2)X \sim N(\mu, \sigma^2)

  • σ2\sigma^2: variance parameter of the Normal.
  • Estimated from data: σ^2=1n−1∑(xi−xˉ)2\hat{\sigma}^2 = \frac{1}{n-1}\sum(x_i - \bar{x})^2 (sample variance, Bessel's correction).

The formula in words

"For a Normal distribution, the variance is the parameter σ² — the square of the standard deviation that controls spread."

Critical Concepts

  • MLE of σ2\sigma^2: σ^MLE2=1n∑(xi−xˉ)2\hat{\sigma}^2_{\text{MLE}} = \frac{1}{n}\sum(x_i - \bar{x})^2 (biased).
  • Unbiased estimator: divide by n−1n-1 (sample variance).
  • σ2\sigma^2 and μ\mu are independent for Normal distribution.
  • For heteroscedastic models (variance varies with xx), σ2\sigma^2 becomes σ2(x)\sigma^2(x).

Step-by-step calculation (tiny example)

Step 1: Data [95, 100, 105, 98, 102], μ=100

Step 2: Squared deviations (95−100)2=25(95-100)^2=25, (100−100)2=0(100-100)^2=0, (105−100)2=25(105-100)^2=25, (98−100)2=4(98-100)^2=4, (102−100)2=4(102-100)^2=4

Step 3: Sample variance (n-1=4) σ^2=(25+0+25+4+4)/4=58/4=14.5\hat{\sigma}^2 = (25+0+25+4+4)/4 = 58/4 = 14.5

Code examples

Beginner example (Python)

python
import numpy as np
from scipy.stats import norm
data = np.array([95, 100, 105, 98, 102], dtype=float)
sigma2_sample = np.var(data, ddof=1)   # unbiased (n-1)
sigma2_mle = np.var(data)   # MLE (n)
print(f"Sample variance (n-1): {sigma2_sample:.2f}")   # 14.5
print(f"MLE variance (n): {sigma2_mle:.2f}")   # 11.6 # Fitted Normal
fitted = norm(loc=data.mean(), scale=np.sqrt(sigma2_sample))
print(f"Fitted Var(X) = σ² = {fitted.var():.2f}")

Beginner example (R)

r
data <- c(95, 100, 105, 98, 102)
cat(sprintf("Sample variance: %.2f\n", var(data)))  # 14.5
cat(sprintf("Population var: %.2f\n", var(data) * (length(data)-1)/length(data)))

Professional example (Python)

python
import numpy as np
from scipy.stats import norm

def normal_sample_size_for_power( effect_size_delta: float, population_std: float, alpha: float = 0.05, power: float = 0.80 ) -> int:
    """Compute required sample size for Normal mean test. Uses variance σ² to compute effect size and required n. Args: effect_size_delta: Minimum detectable difference in means. population_std: σ, standard deviation. alpha: Type I error rate. power: 1 - Type II error rate. Returns: Required sample size per group. """
    z_alpha = norm.ppf(1 - alpha / 2)
    z_beta = norm.ppf(power)
    n = ((z_alpha + z_beta) ** 2 * population_std ** 2) / (effect_size_delta ** 2)
    return int(np.ceil(n))   # Sample size sensitivity to σ
sigma_values = [0.5, 1.0, 1.5, 2.0, 3.0]
delta = 0.5   # detectable difference
print(f"Required n per group (delta={delta}, alpha=0.05, power=0.80):")
for sigma_val in sigma_values:
    n_required = normal_sample_size_for_power(delta, sigma_val)
print(f" σ={sigma_val:.1f} (σ²={sigma_val**2:.2f}): n={n_required:,}")

Source: domain knowledge

#probability-statistics#statistical-operations-and-random-variables#common-continuous-distributions

Keyboard shortcuts

Single keys, ignored while typing in a field or with Cmd, Ctrl or Alt held.

0
Home
1 2 3 4
Work, Writing, Tools, About
j / k
Next / previous section on this page
n / p
Next / previous project or essay
u
Up one level
l
Deutsch
t
Light or dark theme
?
This list
Esc
Close