V.2 · Statistics
What does the area of a deviation square measure?
Connect squared distances to two variance conventions, then compare them with the median and unscaled median absolute deviation.
Square deviations; compare robust spread
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Squared deviations total 22. Divide by n for population variance, by n−1 for usual sample variance. Median absolute deviation (MAD) = 1.
Select an observation below. Drag its handle or use Left/Right arrows; Shift takes a larger step. Numeric entry accepts two decimal places.
Ordered: 1, 2, 2, 3, 7
Single mode: 2.
Observed values · counts · dashed marker is the observed mean
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Squared deviations total 22. Divide by n for population variance, by n−1 for usual sample variance. Median absolute deviation (MAD) = 1.
- Observed mean
- 3
- Observed median
- 2
- Population variance of these observations
- 4.4
- Usual sample variance
- 5.5
- Population standard deviation
- √110/52.097618…
- Median absolute deviation (unscaled)
- 1
= exact finite-data/model quantity · ≈ binary64 approximation; empirical results describe this run
from −20 to 20, up to 2 decimal places
Squared deviations total 22. Divide by n for population variance, by n−1 for usual sample variance. Median absolute deviation (MAD) = 1.
Order actual observations
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Squared deviations total 22. Divide by n for population variance, by n−1 for usual sample variance. Median absolute deviation (MAD) = 1.
Intuition
Two datasets can share a center and have very different spreads. The mean-centered deviation measures signed displacement; summing deviations gives zero and loses spread. Squaring keeps all distances nonnegative, and the square pictures make large deviations visibly influential.
Definition
Population variance of these finite observations is . Usual sample variance is for . Their standard deviations are the nonnegative square roots. The unscaled median absolute deviation is , where is the observed median.
Mechanics
Move or select observed values. Every square area is proportional to its displayed squared deviation; all squares share a scale within the dataset. The histogram, inspector and immutable replay use the same observations. The one-observation preset deliberately makes the usual sample variance undefined.
Derivation
Expansion yields . For iid data with finite population variance , . Division by makes unbiased for that model; it does not imply that is an unbiased estimator of .
Worked examples
For , mean 2 gives deviations and squared sum 2. Thus and . For , median 2 gives absolute distances , whose median is 1. The variance reacts strongly to 20; MAD remains 1.
Worked example: Square deviations; compare robust spread
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Squared deviations total 22. Divide by n for population variance, by n−1 for usual sample variance. Median absolute deviation (MAD) = 1.
Select an observation below. Drag its handle or use Left/Right arrows; Shift takes a larger step. Numeric entry accepts two decimal places.
Ordered: 1, 2, 2, 3, 7
Single mode: 2.
Observed values · counts · dashed marker is the observed mean
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Squared deviations total 22. Divide by n for population variance, by n−1 for usual sample variance. Median absolute deviation (MAD) = 1.
- Observed mean
- 3
- Observed median
- 2
- Population variance of these observations
- 4.4
- Usual sample variance
- 5.5
- Population standard deviation
- √110/52.097618…
- Median absolute deviation (unscaled)
- 1
= exact finite-data/model quantity · ≈ binary64 approximation; empirical results describe this run
from −20 to 20, up to 2 decimal places
Squared deviations total 22. Divide by n for population variance, by n−1 for usual sample variance. Median absolute deviation (MAD) = 1.
Order actual observations
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Squared deviations total 22. Divide by n for population variance, by n−1 for usual sample variance. Median absolute deviation (MAD) = 1.
Executable reference code
Run both files. The pedagogical program exposes the arithmetic; the NumPy companion uses array operations. Literal assertions check the worked example rather than testing a simulation against a desired statistical outcome.
"""Runnable spread reference; exact mechanics / NumPy companion."""
from fractions import Fraction as F
from statistics import median
x=list(map(F,[1,2,3]))
mean=sum(x)/len(x)
squared_sum=sum((v-mean)**2 for v in x)
variance=squared_sum/len(x)
sample=squared_sum/(len(x)-1) if len(x)>1 else None
mad=median([abs(v-median(x)) for v in x])
assert (variance,sample,mad)==(F(2,3),F(1),F(1))
print(variance,sample,mad)"""Runnable spread reference; exact mechanics / NumPy companion."""
import numpy as np
x=np.array([1.,2.,3.])
variance=x.var(ddof=0)
sample=x.var(ddof=1) if len(x)>1 else None
mad=np.median(np.abs(x-np.median(x)))
assert np.isclose(variance,2/3) and sample==1 and mad==1
print(variance,sample,mad)Explore
Move the extreme observation while keeping the middle values fixed. Predict which center and spread will change. Add the same constant to every value; then multiply all observations by two. Variances scale by four, standard deviations and MAD by two.
Common mistakes and counterexamples
A small MAD need not mean every observation is close to the median: a minority of extreme points can coexist with a small central spread. MAD can be zero in a nonconstant discrete dataset when enough values coincide. Robust means resistant to some contamination, not immune to every change.
Numerical considerations
All supported centered sums and rational variance identities are exact. Square roots and drawing coordinates use binary64; exact root forms are displayed when supported. Raw second-moment subtraction is dangerous for large nearly equal floating values; the teaching model centers exact fractions and bounds inputs. Unscaled MAD is not automatically a Gaussian standard-deviation estimate.
Engineering and ML connections
Feature scaling and uncertainty estimates need a stated spread convention. Standard deviation measures squared-error scale, while median/MAD can help diagnose contaminated measurements. The factor 1.4826 sometimes applied to MAD assumes a normal calibration; this explorer deliberately uses the unscaled descriptive quantity.
Exercises
Predict, calculate and explain before checking the corrective feedback. Each solution states the relevant rule and its conditions.
Summary and checkpoints
Identify which denominator is appropriate, calculate a squared sum, explain the singleton exception and compare ordinary with robust summaries. Units matter: variance has squared units; standard deviation and MAD return to the observation units.