V.4 · Statistics
How does an estimator behave across samples?
Apply a fixed estimator to real seeded samples and separate theoretical bias and variance from the exact decomposition observed in one finite run.
Repeat an estimator, inspect its errors
Estimate values · frequency counts · dashed marker is the fixed population mean
Fixed population: 0, 1, 2, 3, 6, 7, 8, 9. Sampling is with replacement.
| Run | Observations | Mean | Estimate |
|---|---|---|---|
| 1 | 2, 0, 6, 1 | 2.25 | 2.25 |
| 2 | 3, 0, 3, 0 | 1.5 | 1.5 |
| 3 | 8, 9, 8, 3 | 7 | 7 |
| 4 | 7, 8, 6, 0 | 5.25 | 5.25 |
| 5 | 1, 9, 9, 9 | 7 | 7 |
| 6 | 6, 1, 6, 2 | 3.75 | 3.75 |
| 7 | 9, 8, 1, 8 | 6.5 | 6.5 |
| 8 | 3, 0, 0, 6 | 2.25 | 2.25 |
| 9 | 8, 8, 7, 3 | 6.5 | 6.5 |
| 10 | 6, 7, 7, 7 | 6.75 | 6.75 |
| 11 | 9, 3, 0, 1 | 3.25 | 3.25 |
| 12 | 3, 1, 8, 6 | 4.5 | 4.5 |
| 13 | 8, 3, 1, 2 | 3.5 | 3.5 |
| 14 | 0, 2, 2, 9 | 3.25 | 3.25 |
| 15 | 9, 1, 8, 6 | 6 | 6 |
| 16 | 2, 2, 1, 9 | 3.5 | 3.5 |
| 17 | 0, 9, 8, 3 | 5 | 5 |
| 18 | 7, 2, 0, 6 | 3.75 | 3.75 |
| 19 | 0, 1, 6, 7 | 3.5 | 3.5 |
| 20 | 3, 1, 1, 7 | 3 | 3 |
| 21 | 9, 8, 7, 8 | 8 | 8 |
| 22 | 3, 1, 1, 6 | 2.75 | 2.75 |
| 23 | 7, 9, 3, 7 | 6.5 | 6.5 |
| 24 | 3, 0, 0, 8 | 2.75 | 2.75 |
Population: 0, 1, 2, 3, 6, 7, 8, 9. Sample one: 2, 0, 6, 1. Every displayed estimate uses its actual sample. Fixed population mean = 4.5. Uniform sampling with replacement: samples vary without selection bias. Theoretical estimator bias = 0; finite-run bias = 0.
- Fixed population mean
- 4.5
- Theoretical estimator bias
- 0
- Theoretical sampling variance
- 2.5625
- Finite-run mean of estimates
- 4.5
- Finite-run signed bias
- 0
- Finite-run variance (divide by R)
- 637/1923.317708…
- Finite-run MSE
- 637/1923.317708…
= exact finite-data/model quantity · ≈ binary64 approximation; empirical results describe this run
from 0 to 4294967295, whole numbers only
from 1 to 32, whole numbers only
from 1 to 64, whole numbers only
from −5 to 5, up to 2 decimal places
Fixed population mean = 4.5. Uniform sampling with replacement: samples vary without selection bias. Theoretical estimator bias = 0; finite-run bias = 0.
Fix the target and selection rule
Fixed population mean = 4.5. Uniform sampling with replacement: samples vary without selection bias. Theoretical estimator bias = 0; finite-run bias = 0.
Intuition
An estimator is a rule that accepts data; an estimate is the output after one sample is observed. Repeating the data-generating experiment produces a distribution of outputs. Its center and spread describe the rule, while one run only reveals a finite collection of estimates.
Definition
The explorer uses for a chosen shift . Relative to fixed target , theoretical bias is , sampling variance is , and mean squared error is . These quantities average over the specified sampling law, not over a selected favorable simulation.
Mechanics
Change the shift, sampling rule, seed, sample size and repetition count. Inspect each complete sample, its mean and resulting estimate. The empirical inspector uses all displayed estimates with denominator R. Its exact finite-run values are kept separate from independently calculated theoretical properties.
Derivation
Write . Expanding and using gives . The analogous finite-list identity holds around its empirical mean when variance divides by R. Using R−1 would require a corresponding correction and would not give this displayed identity.
Worked examples
Uniform sampling at with shift gives theoretical bias 1 and variance , so MSE is . For the actual first sample , the estimate is . For hand estimates targeting 1, empirical bias is 0, variance is 1 and MSE is 1.
Worked example: Repeat an estimator, inspect its errors
Estimate values · frequency counts · dashed marker is the fixed population mean
Fixed population: 0, 1, 2, 3, 6, 7, 8, 9. Sampling is with replacement.
| Run | Observations | Mean | Estimate |
|---|---|---|---|
| 1 | 2, 0, 6, 1 | 2.25 | 2.25 |
| 2 | 3, 0, 3, 0 | 1.5 | 1.5 |
| 3 | 8, 9, 8, 3 | 7 | 7 |
| 4 | 7, 8, 6, 0 | 5.25 | 5.25 |
| 5 | 1, 9, 9, 9 | 7 | 7 |
| 6 | 6, 1, 6, 2 | 3.75 | 3.75 |
| 7 | 9, 8, 1, 8 | 6.5 | 6.5 |
| 8 | 3, 0, 0, 6 | 2.25 | 2.25 |
| 9 | 8, 8, 7, 3 | 6.5 | 6.5 |
| 10 | 6, 7, 7, 7 | 6.75 | 6.75 |
| 11 | 9, 3, 0, 1 | 3.25 | 3.25 |
| 12 | 3, 1, 8, 6 | 4.5 | 4.5 |
| 13 | 8, 3, 1, 2 | 3.5 | 3.5 |
| 14 | 0, 2, 2, 9 | 3.25 | 3.25 |
| 15 | 9, 1, 8, 6 | 6 | 6 |
| 16 | 2, 2, 1, 9 | 3.5 | 3.5 |
| 17 | 0, 9, 8, 3 | 5 | 5 |
| 18 | 7, 2, 0, 6 | 3.75 | 3.75 |
| 19 | 0, 1, 6, 7 | 3.5 | 3.5 |
| 20 | 3, 1, 1, 7 | 3 | 3 |
| 21 | 9, 8, 7, 8 | 8 | 8 |
| 22 | 3, 1, 1, 6 | 2.75 | 2.75 |
| 23 | 7, 9, 3, 7 | 6.5 | 6.5 |
| 24 | 3, 0, 0, 8 | 2.75 | 2.75 |
Population: 0, 1, 2, 3, 6, 7, 8, 9. Sample one: 2, 0, 6, 1. Every displayed estimate uses its actual sample. Fixed population mean = 4.5. Uniform sampling with replacement: samples vary without selection bias. Theoretical estimator bias = 0; finite-run bias = 0.
- Fixed population mean
- 4.5
- Theoretical estimator bias
- 0
- Theoretical sampling variance
- 2.5625
- Finite-run mean of estimates
- 4.5
- Finite-run signed bias
- 0
- Finite-run variance (divide by R)
- 637/1923.317708…
- Finite-run MSE
- 637/1923.317708…
= exact finite-data/model quantity · ≈ binary64 approximation; empirical results describe this run
from 0 to 4294967295, whole numbers only
from 1 to 32, whole numbers only
from 1 to 64, whole numbers only
from −5 to 5, up to 2 decimal places
Fixed population mean = 4.5. Uniform sampling with replacement: samples vary without selection bias. Theoretical estimator bias = 0; finite-run bias = 0.
Fix the target and selection rule
Fixed population mean = 4.5. Uniform sampling with replacement: samples vary without selection bias. Theoretical estimator bias = 0; finite-run bias = 0.
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 estimators reference; exact mechanics / NumPy companion."""
from fractions import Fraction as F
estimates=list(map(F,[0,2]))
target=F(1)
mean=sum(estimates)/len(estimates)
bias=mean-target
variance=sum((x-mean)**2 for x in estimates)/len(estimates)
mse=sum((x-target)**2 for x in estimates)/len(estimates)
assert (bias,variance,mse)==(F(0),F(1),F(1))
assert mse==variance+bias*bias
print(bias,variance,mse)"""Runnable estimators reference; exact mechanics / NumPy companion."""
import numpy as np
estimates=np.array([0.,2.]); target=1.
bias=estimates.mean()-target
variance=estimates.var(ddof=0)
mse=np.mean((estimates-target)**2)
assert bias==0 and variance==1 and mse==1
assert np.isclose(mse,variance+bias**2)
print(bias,variance,mse)Explore
Compare unbiased mean, shifted mean and biased selection. Keep the target fixed. Find a seed whose empirical signed bias disagrees with theoretical bias, then explain why this does not invalidate the theoretical formula. Increasing R refines a simulation; increasing n changes the estimator distribution.
Common mistakes and counterexamples
Finite-run agreement with a target does not prove unbiasedness. A theoretical unbiased estimator can have large sampling variance, and a biased estimator can have smaller MSE for a particular problem. Do not edit samples to make their empirical average equal the claimed expectation.
Numerical considerations
The population and selected-source moments are computed directly with rational arithmetic. Actual sample estimates and finite-run MSE identities remain exact. Theoretical standard errors are binary64 square roots. At R=1 empirical variance is zero even if theoretical sampling variance is positive; one realization cannot describe its full variability.
Engineering and ML connections
Validation scores, Monte Carlo estimates and sensor calibration are outputs of procedures. Compare error across repeated samples and distinguish systematic offset from random spread. Later regularization can trade bias against variance, but the tradeoff must be measured under a stated target and sampling law.
Exercises
Predict, calculate and explain before checking the corrective feedback. Each solution states the relevant rule and its conditions.
Summary and checkpoints
Distinguish rule from result, target from estimate, and theory from finite simulation. Derive MSE decomposition and explain why both squared bias and sampling variance matter.