V.1 · Statistics
How much can one observation move the center?
Move a real observation and compare the mean, median and frequency counts. Ordered values, plotted observations and summaries share one exact dataset.
Move observations, follow the summaries
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Mean = 3; median = 2. Single mode: 2.
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. Mean = 3; median = 2. Single mode: 2.
- 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
Mean = 3; median = 2. Single mode: 2.
Order actual observations
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Mean = 3; median = 2. Single mode: 2.
Intuition
The mean is a balance point: every observation contributes to the sum. The median asks where the ordered middle lies. A mode asks which observed value occurs most often. They answer different questions, so disagreement can be useful information. Try moving the selected 7 to 20 before reading on.
Definition
For a nonempty dataset , the mean is . Order the observations as . For odd , the median is ; for even , average and . Modes maximize observed frequency.
Mechanics
Select an observation by its numbered button, then drag its number-line handle, use arrow keys, or enter a value. Add or remove observations and watch the ordered list and histogram update. Values may repeat: the frequency view keeps counts while the number line can show coincident points. Reset restores [1,2,2,3,7].
Derivation
The mean uniquely minimizes : expanding around gives . By contrast, a median minimizes the sum of absolute distances; for an even dataset a whole interval can minimize that objective, while our reported convention averages the middle pair.
Worked examples
For , the sum is 15, so the mean is 3. The middle observation is 2 and its frequency is 2: median and single mode are both 2. Replacing 7 by 20 gives mean and the same median 2. For , both 1 and 3 are modes.
Worked example: Move observations, follow the summaries
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Mean = 3; median = 2. Single mode: 2.
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. Mean = 3; median = 2. Single mode: 2.
- 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
Mean = 3; median = 2. Single mode: 2.
Order actual observations
Ordered observed values: 1, 2, 2, 3, 7. Single mode: 2. Mean = 3; median = 2. Single mode: 2.
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 summaries reference; exact mechanics / NumPy companion."""
from fractions import Fraction as F
from collections import Counter
x = [F(v) for v in [1,2,2,3,7]]
a = sorted(x)
mean = sum(x)/len(x)
median = a[len(a)//2]
counts = Counter(x)
modes = [v for v,c in counts.items() if c == max(counts.values())]
assert (mean,median,modes)==(F(3),F(2),[F(2)])
print(mean, median, modes)"""Runnable summaries reference; exact mechanics / NumPy companion."""
import numpy as np
x=np.array([1,2,2,3,7],dtype=float)
values, counts=np.unique(x,return_counts=True)
modes=values[counts==counts.max()]
assert x.mean()==3 and np.median(x)==2 and modes.tolist()==[2]
print(x.mean(),np.median(x),modes)Explore
Compare the outlier, singleton, multiple-mode and distinct-value presets. Predict the result before moving a point. Find two different datasets with the same mean but different medians; then explain why one number cannot reconstruct the observations.
Common mistakes and counterexamples
Do not choose a tied mode arbitrarily. When every distinct value occurs once, every value ties for maximal frequency; this explorer reports no repeated value and no uniquely determined mode. Some textbooks call every tied value a mode. This declared convention avoids implying a preferred value. A singleton has its own value as all three summaries.
Numerical considerations
Inputs contain at most two decimal places and lie between −20 and 20; datasets have 1–24 observations. Sorting, sums, medians and frequency equality use exact rational arithmetic. Rendering converts these exact values to binary64 coordinates. Rounded inspector companions use ≈, while observed fractions use =. The plot reports data values, not unknown population parameters.
Engineering and ML connections
Latency, sensor readings and feature distributions often have a long right tail. A mean can reveal total load, while a median describes a typical ordered observation. A mode is useful for discrete categories but depends on bin choices for continuous data; this chapter uses actual repeated values rather than inventing histogram modes.
Exercises
Predict, calculate and explain before checking the corrective feedback. Each solution states the relevant rule and its conditions.
Summary and checkpoints
Check that you can order observations, distinguish three definitions, calculate an even median, retain mode ties and explain an outlier. A summary compresses observations; always retain enough of the dataset to inspect what it hides.