Pragmastat:
Pragmatic Statistical Toolkit

Andrey Akinshin
Version 1.0.0
Python · TypeScript · R · .NET · Kotlin · Rust · Go
$$ % Samples \newcommand{\x}{\mathbf{x}} \newcommand{\y}{\mathbf{y}} % One-sample estimators \newcommand{\Center}{\operatorname{Center}} \newcommand{\Spread}{\operatorname{Spread}} \newcommand{\Volatility}{\operatorname{Volatility}} \newcommand{\Precision}{\operatorname{Precision}} % Two-sample estimators \newcommand{\MedShift}{\operatorname{MedShift}} \newcommand{\MedRatio}{\operatorname{MedRatio}} \newcommand{\MedSpread}{\operatorname{MedSpread}} \newcommand{\MedDisparity}{\operatorname{MedDisparity}} % Misc \renewcommand{\Pr}{\mathbb{P}} % Probability \newcommand{\Var}{\mathbb{V}} % Variance \newcommand{\E}{\mathbb{E}} % Expected value \newcommand{\eff}{\operatorname{eff}} % Efficiency % Not-recommended traditional estimators \newcommand{\Median}{\operatorname{Median}} \newcommand{\Mean}{\operatorname{Mean}} \newcommand{\StdDev}{\operatorname{StdDev}} \newcommand{\MAD}{\operatorname{MAD}} \newcommand{\RC}{\operatorname{RC}} $$

This manual presents a unified statistical toolkit for reliable analysis of real-world data. The toolkit nearly matches the efficiency of traditional statistical estimators under normality, has practically reasonable robustness, enables simple software implementations without advanced statistical libraries, and provides clear explanations accessible to practitioners without deep statistical training. The toolkit consists of renamed, recombined, and refined versions of existing methods.

Table of Content

Toolkit

This section provides statistical estimators for summarizing a single sample and comparing two samples.

One-Sample Summary

Consider a sample $\x$ of $n$ real numbers: $\x = (x_1, x_2, \ldots, x_n)$. The toolkit provides four estimators to summarize key properties of the data and provide insights into the data’s primary characteristics:

$$ \Center(\x) = \underset{1 \leq i \leq j \leq n}{\Median} \left(\frac{x_i + x_j}{2} \right) $$$$ \Spread(\x) = \underset{1 \leq i < j \leq n}{\Median} |x_i - x_j| $$$$ \Volatility(\x) = \frac{\Spread(\x)}{\left| \Center(\x) \right|} $$$$ \Precision(\x) = \frac{2 \cdot \Spread(\x)}{\sqrt{n}} $$

One-sample summary statistics work best for unimodal distributions and distributions with low dispersion.

$\Center(\x)$1 estimates the central (average) value of the distribution. For normal distributions, it matches both the mean and the median. It outperforms traditional estimators in practical use. Compared to $\Mean$, $\Center$ is much more robust (tolerates almost one-third of outliers). Compared to $\Median$, $\Center$ is much more efficient and requires $1.5$ times fewer observations to achieve the same precision.

$\Spread(\x)$2 estimates distribution dispersion (variability or scatter). It measures the median absolute difference between two random sample elements. This measure offers a practical alternative to standard deviation ($\StdDev$) and median absolute deviation ($\MAD$). Compared to $\StdDev$, $\Spread$ is more robust (standard deviation breaks with a single extreme value) and has comparable efficiency under normality. Compared to $\MAD$, $\Spread$ is much more efficient under normality and requires $2.35$ times fewer observations to achieve the same precision.

$\Volatility(\x)$ estimates the relative dispersion of the distribution. Convenient to express in percentage: e.g., a value of $0.2$ means $20\%$ relative to $\Center(\x)$. $\Volatility$ is scale-invariant, which makes an experiment design more portable.

$\Precision(\x)$ estimates the distance between two $\Center$ estimations of independent random samples. The interval $\Center(\x) \pm \Precision(\x)$ forms a range that contains the true center value with high confidence. For even higher confidence, use $\Center(\x) \pm 2 \cdot \Precision(\x)$ or $\Center(\x) \pm 3 \cdot \Precision(\x)$.

These estimators build on $\Median(\x)$3. To find the median, $\x$ must first be arranged into a sorted sample4: $(x_{(1)}, \ldots, x_{(n)})$. In this ordered sequence, $x_{(1)}$ represents the smallest value and $x_{(n)}$ the largest. The median then becomes the middle value of this sorted sample. When the sample size is even, the median equals the average of the two middle values:

$$ \Median(\x) = \begin{cases} x_{\left((n+1)/2\right)} & \text{if } n \text{ is odd} \\ \frac{x_{(n/2)} + x_{(n/2+1)}}{2} & \text{if } n \text{ is even} \end{cases} $$

Two-Sample Summary

Consider a second sample $\y$ of $m$ real numbers: $\y = (y_1, \ldots, y_m)$. Estimators to compare $\x$ and $\y$:

$$ \MedShift(\x, \y) = \underset{1 \leq i \leq n,\,\, 1 \leq j \leq m}{\Median} \left(x_i - y_j \right) $$$$ \MedRatio(\x, \y) = \underset{1 \leq i \leq n,\,\, 1 \leq j \leq m}{\Median} \left( \dfrac{x_i}{y_j} \right) $$$$ \MedSpread(\x, \y) = \dfrac{n\Spread(\x) + m\Spread(\y)}{n + m} $$$$ \MedDisparity(\x, \y) = \dfrac{\MedShift(\x, \y)}{\MedSpread(\x, \y)} $$

These estimators work best for unimodal or narrow distributions, capturing the typical differences between $\x$ and $\y$.

$\MedShift(\x, \y)$5 estimates the median absolute difference between elements of $\x$ and $\y$. It answers “by how much does $\x$ typically exceed $\y$?” in the original units. The sign matters: positive means $\x$ is typically larger, negative means $\y$ is typically larger. E.g., $\MedShift$ of $-5$ means that in $50\%$ of $(x_i, y_j)$ pairs, $y_j - x_i > 5$.

$\MedRatio(\x, \y)$6 estimates the median ratio of $\x$ elements to $\y$ elements. It answers “what’s the typical ratio between $\x$ and $\y$?” as a multiplier. For example, $\MedRatio = 1.2$ means that in $50\%$ of $(x_i, y_j)$ pairs, $x_i$ is larger than $y_j$ by at least $20\%$. Express as percentage change: $(\MedRatio - 1) \times 100\%$. $\MedRatio$ is scale-invariant, which makes an experiment design more portable.

$\MedSpread(\x, \y)$ estimates the averaged variability when considering both samples together. The measure computes the weighted average of individual spreads, where larger samples contribute more. This value primarily serves as a scaling factor for $\MedDisparity$. It represents the typical variability in the combined data and works best for distributions with similar dispersion values.

$\MedDisparity(\x, \y)$7 estimates a normalized absolute difference between $\x$ and $\y$ expressed in standardized spread units. Negative values are treated similarly to $\MedShift(\x, \y)$. $\MedDisparity$ is scale-invariant, which makes an experiment design more portable.

Estimators

This section explains each estimator’s key properties, selection rationale, and advantages over traditional methods.

Center

$$ \Center(\x) = \underset{1 \leq i \leq j \leq n}{\Median} \left(\frac{x_i + x_j}{2} \right) $$

Practical Recommendations

$\Center$ provides an initial insight into the magnitude of sample values. When $\Volatility$ is small, the whole sample can be approximated by the $\Center$ value.

Key Facts

Comparison

Properties

$$ \Center(\x + k) = \Center(\x) + k $$$$ \Center(k \cdot \x) = k \cdot \Center(\x) $$

Spread

$$ \Spread(\x) = \underset{i < j}{\Median} |x_i - x_j| $$

Practical Recommendations

$\Spread$ provides an initial insight into the dispersion of the sample values. Interpretation: half of $|x_i-x_j|$ is smaller than $\Spread(\x)$, the other half is larger.

Key Facts

Comparison

Empirical Rule

For the standard normal distribution, the asymptotic 68–95–99.7 rule becomes the 66-94-99.6 rule:

Properties

$$ \Spread(\x + k) = \Spread(\x) $$$$ \Spread(k \cdot \x) = |k| \cdot \Spread(\x) $$$$ \Spread(x) \geq 0 $$

Volatility

$$ \Volatility(\x) = \frac{\Spread(\x)}{\left| \Center(\x) \right|} $$

Practical Recommendations

$\Volatility$ provides a scale-invariant insight into the distribution dispersion normalized by the center value.

Interpretation examples:

Key Facts

Properties

$$ \Volatility(k \cdot \x) = \Volatility(\x) $$$$ \Volatility(x) \geq 0 $$

Precision

$$ \Precision(\x) = \frac{2 \cdot \Spread(\x)}{\sqrt{n}} $$

Practical Recommendations

The interval $\Center(\x) \pm k \cdot \Precision(\x)$ contains the true center value with probability depending on $k$. Select $k \in \{1, 2, 3\}$ based on required confidence.

Low error costs: $\Center(\x) \pm \Precision(\x)$ provides a reasonable interval.
High error costs: repeat the experiment 3–5 times and use $\Center(\x) \pm 2 \cdot \Precision(\x)$.
Critical applications: repeat the experiment 7–10 times and use $\Center(\x) \pm 3 \cdot \Precision(\x)$.

Key Facts

Properties

$$ \Precision(\x + k) = \Precision(\x) $$$$ \Precision(k \cdot \x) = |k| \cdot \Precision(\x) $$$$ \Precision(\x) \geq 0 $$

Comments on default factor of 2

Practitioners tend to perceive estimations $a \pm b$ as “the value is inside $[a-b; a+b]$” ignoring uncertainty. The unscaled interval $\Center(x) \pm \Spread(\x)/\sqrt{n}$ covers the true distribution center value only in $\approx 65\%$ of cases. To reduce risks of misinterpretation of $\Center(\x) \pm \Precision(\x)$, it is reasonable to use the default factor for $\Precision(\x)$ to ensure high coverage of such intervals for the true distribution center value. For simpler calculations, it’s convenient to use natural numbers as scale factors for $\Precision(\x)$. The factor of $2$ is chosen since it’s the smallest natural number that ensures decent coverage. Natural coefficients $k$ produce a standardized discrete precision scale with values of $k \cdot \Precision(\x)$ or $2k \cdot \Spread(\x) / \sqrt{n}$.

Relation between Precision and Confidence Intervals

In the strict normal model, it’s convenient to express precision via the standard error (the standard deviation divided by the square root of sample size). The standard error can be scaled to the margin of error (half of a confidence interval) for the given confidence level. Choosing between confidence levels — $95\%$, $99\%$, $99.9\%$, or even $89\%$8 — remains arbitrary. Practitioners struggle to extract insights from confidence intervals and levels without calculation tools. This difficulty leads to frequent misinterpretation because no standard exists for choosing levels. Knowing one confidence interval determines all others through constant relationships, yet practitioners report two numbers (interval size and confidence level) that are hard to comprehend together. A single standardized value would serve practitioners better.

A standardized value simplifies reporting and improves consistency. A memorable definition enables mental calculation without advanced tools. Practitioners develop intuition through repeated use.

$\Precision$ has no direct mapping into traditional confidence intervals. Confidence intervals ensure the declared coverage rate only under perfect normality. Real data provides no guarantees that a $99\%$ confidence interval actually covers the true value in $99\%$ of experiments. The table below shows the translation from $\Center(\x) \pm k \cdot \Precision(\x)$ to confidence levels under normality:

nk=1k=2k=3
20.783640.888620.92534
30.886600.967410.98507
40.895230.981450.99413
50.885600.978260.99282
60.900690.986740.99675
70.902200.989650.99803
80.908020.991750.99861
90.912300.993680.99917
100.914610.994830.99946
110.916870.995560.99960
120.918860.996260.99973
130.920220.996780.99980
140.921560.997140.99984
150.922910.997480.99988
160.923840.997700.99991
170.924470.997960.99993
180.925340.998130.99994
190.926290.998280.99995
200.926910.998410.99996
210.927200.998530.99997
220.927800.998640.99998
230.928170.998710.99998
240.928890.998790.99998
250.929160.998830.99998
260.929450.998920.99999
270.929790.998970.99999
280.930060.999020.99999
290.930290.999070.99999
300.930510.999090.99999

MedShift

$$ \MedShift(\x, \y) = \underset{1 \leq i \leq n,\,\, 1 \leq j \leq m}{\Median} \left(x_i - y_j \right) $$

Practical Recommendations

$\MedShift$ provides an initial insight into the absolute difference between elements of two samples. Interpretation: half of $x_i-y_j$ is smaller than $\MedShift(\x, \y)$, the other half is larger. For samples with small $\Volatility$, $\MedShift(\x, \y)$ approximates pairwise differences $x_i - y_j$.

Key Facts

Properties

$$ \MedShift(\x + k_x, \y + k_y) = \MedShift(\x, \y) + k_x\!-\!k_y $$$$ \MedShift(k \cdot \x, k \cdot \y) = k \cdot \MedShift(\x, \y) $$$$ \MedShift(\x, \y) = - \MedShift(\y, \x) $$

MedRatio

$$ \MedRatio(\x, \y) = \underset{1 \leq i \leq n,\,\, 1 \leq j \leq m}{\Median} \left( \dfrac{x_i}{y_j} \right) $$

Practical Recommendations

$\MedRatio$ provides an initial insight into the ratio between elements of two samples expressed as a multiplicative factor. It answers “how many times larger is $\x$ compared to $\y$?” E.g., $\MedRatio = 2.0$ means that for $50\%$ of pairs $(x_i, y_j)$, $x_i$ is at least twice as large as $y_j$.

$\MedRatio$ functions as a division operator: $\MedRatio(\x, \y)$ computes the typical ratio $\x / \y$. Results convert to percentage differences as $(\MedRatio - 1) \times 100\%$.

Key Facts

Properties

$$ \MedRatio(k_x \cdot \x, k_y \cdot \y) = \frac{k_x}{k_y} \cdot \MedRatio(\x, \y) $$

MedSpread

$$ \MedSpread(\x, \y) = \dfrac{n\Spread(\x) + m\Spread(\y)}{n + m} $$

Practical Recommendations

$\MedSpread$ primarily serves as a scaling factor for $\MedDisparity$. It represents the combined dispersion of both samples, weighted by sample size. Works best for distributions with similar dispersion values.

Key Facts

Properties

$$ \MedSpread(\x, \x) = \Spread(\x) $$$$ \MedSpread(k_1 \cdot \x, k_2 \cdot \x) = \frac{ |k_1| + |k_2| }{2} \cdot \Spread(\x) $$$$ \MedSpread(\x, \y) = \MedSpread(\y, \x) $$$$ \MedSpread(k \cdot \x, k \cdot \y) = |k| \cdot \MedSpread(\x, \y) $$

MedDisparity

$$ \MedDisparity(\x, \y) = \dfrac{\MedShift(\x, \y)}{\MedSpread(\x, \y)} $$

Practical Recommendations

$\MedDisparity$ provides a scale-invariant insight into the absolute difference between elements of two samples, expressed in standardized spread units.

Key Facts

Comparison

Properties

$$ \MedDisparity(\x + k, \y + k) = \MedDisparity(\x, \y) $$$$ \MedDisparity(k\!\cdot\!\x, k\!\cdot\!\y) = \operatorname{sign}(k)\!\cdot\!\MedDisparity(\x, \y) $$$$ \MedDisparity(\x, \y) = -\MedDisparity(\y, \x) $$

Studies

This section analyzes the estimators’ properties using mathematical proofs and Monte Carlo simulations. Most proofs are adopted from various textbooks and papers, but only the most essential references are provided.

Unlike the main part of the manual, studies require knowledge of classic statistical methods. Well-known facts and commonly accepted notation are used without special introduction. The studies provide a deep dive into properties of considered estimators for practitioners interested in rigorous proofs and results of numerical simulations.

Asymptotic Gaussian Expected Value of the Spread

This study establishes that $\Spread$ has expected value $\sqrt{2}\,\Phi^{-1}(0.75) \approx 0.954$ under standard normal data as sample size increases.

The key insight is that pairwise absolute differences $|X_i - X_j|$ from normal data converge to a known distribution. Since $\Spread$ takes the median of these differences, its asymptotic expectation equals the population median of $|X_1 - X_2|$ where $X_1, X_2 \stackrel{\mathrm{iid}}{\sim} \mathcal{N}(0, 1)$.

Consider $X_1, \ldots, X_n \stackrel{\mathrm{iid}}{\sim} \mathcal{N}(0, 1)$. For any fixed $i \neq j$, the difference $X_i - X_j$ has mean 0 and variance

$$ \Var[X_i - X_j] = \Var[X_i] + \Var[X_j] = 1 + 1 = 2 $$

because $X_i$ and $X_j$ are independent. Therefore

$$ X_i - X_j \sim \mathcal{N}(0, 2) $$

Define $W = (X_i - X_j)/\sqrt{2} \sim \mathcal{N}(0, 1)$ and $D = |X_i - X_j| = \sqrt{2}\,|W|$. The cumulative distribution function of $D$ for $t \geq 0$ is

$$ \Pr[D \leq t] = \Pr\bigl[|W| \leq t/\sqrt{2}\bigr] = 2\Phi\bigl(t/\sqrt{2}\bigr) - 1 $$

where $\Phi$ denotes the standard normal cumulative distribution function. The population median $m$ of $D$ satisfies

$$ 2\Phi\bigl(m/\sqrt{2}\bigr) - 1 = \tfrac{1}{2} $$

Solving for $m$ yields

$$ m = \sqrt{2}\,\Phi^{-1}(0.75) $$

The multiset of gaps $\{|X_i - X_j| : i < j\}$ forms a bounded-kernel U-statistic of degree 2. U-statistic consistency results imply that its empirical distribution converges almost surely to the law of $D$. The sample median of pairwise differences thus converges in probability to $m$. Convergence in probability plus uniform integrability yields convergence of expectations:

$$ \lim_{n \to \infty} \E\bigl[\Spread(X_1, \ldots, X_n)\bigr] = \sqrt{2}\,\Phi^{-1}(0.75) $$

or

$$ \lim_{n \to \infty} \E\bigl[\Spread(X_1, \ldots, X_n)\bigr] \approx 0.953\,873 $$

Asymptotic Gaussian Efficiency of the Center

This study shows that $\Center$ achieves $3/\pi \approx 95.5\%$ efficiency relative to the sample mean under normality. This high efficiency allows $\Center$ to handle outliers while maintaining near-optimal performance on normal data.

The analysis uses U-statistic theory to derive the asymptotic distribution of $\Center$ under Gaussian data. Let

$$ X_1, \ldots, X_n \stackrel{\mathrm{iid}}{\sim} \mathcal{N}(\mu, \sigma^2), \qquad n \geq 2,\; \sigma > 0 $$

$\Center(\x)$ has translation invariance, so setting $\mu = 0$ preserves generality. The Walsh averages are

$$ W_{ij} = \frac{X_i + X_j}{2}, \qquad 1 \leq i \leq j \leq n $$

Since $X_i + X_j \sim \mathcal{N}(0, 2\sigma^2)$, it follows that

$$ W_{ij} \sim \mathcal{N}\bigl(0, \sigma^2/2\bigr), \qquad f_W(0) = \frac{1}{\sigma\sqrt{\pi}} $$

The estimator $\Center(\x)$ equals the sample median of the $\binom{n+1}{2}$ Walsh averages. As a U-quantile of degree two, it satisfies

$$ 0 = \frac{2}{n(n+1)}\sum_{1 \leq i \leq j \leq n} \Bigl\{\mathbf{1}\{W_{ij} \leq \Center(\x)\} - \tfrac{1}{2}\Bigr\} $$

U-quantile theory sen1963 provides the linear expansion

$$ \sqrt{n}\,\Center(\x) = \frac{2}{f_W(0)} \frac{1}{\sqrt{n}}\sum_{i=1}^{n}\psi(X_i) + o_{\Pr}(1) $$

where

$$ \psi(x) = \Pr\Bigl\{\tfrac{x+X_2}{2} \leq 0\Bigr\} - \tfrac{1}{2} = \tfrac{1}{2} - \Phi\Bigl(\tfrac{x}{\sigma}\Bigr) $$

and $\Phi$ is the standard normal cumulative distribution function. Since $X_1/\sigma \sim \mathcal{N}(0, 1)$,

$$ \Var\bigl[\psi(X_1)\bigr] = \int_{-\infty}^{\infty} \Bigl(\tfrac{1}{2} - \Phi(u)\Bigr)^2\varphi(u)\,du = \frac{1}{12} $$

with $\varphi$ the standard normal probability density function. Substituting $\Var[\psi(X_1)]$ and $f_W(0)$ yields

$$ \Var\bigl[\sqrt{n}\,\Center(\x)\bigr] = \frac{4 \cdot \frac{1}{12}}{\bigl(1/(\sigma\sqrt{\pi})\bigr)^2} = \frac{\pi\sigma^2}{3} $$

so

$$ \sqrt{n}\,\Center(\x) \xrightarrow{d} \mathcal{N}\Bigl(0, \tfrac{\pi\sigma^2}{3}\Bigr), \qquad n \to \infty $$

The sample mean has asymptotic variance $\sigma^2/n$, hence the asymptotic Gaussian efficiency of $\Center$ is

$$ \eff_{\mathcal{N},\infty}(\Center) = \frac{\sigma^2/n}{\pi\sigma^2/(3n)} = \frac{3}{\pi} \approx 0.954\,930 $$

Thus matching the mean’s precision under normality requires only $1/0.955\approx1.05$ times as many observations, a negligible price for the Center’s $29\%$ breakdown point and much stronger resistance to outliers.

Asymptotic Gaussian Efficiency of the Median

This study shows that the sample median achieves only $2/\pi \approx 63.7\%$ efficiency relative to the sample mean under normality.

The analysis applies classical asymptotic theory for sample quantiles to derive the limiting distribution of the median under Gaussian data. Consider

$$ X_1, \ldots, X_n \stackrel{\mathrm{iid}}{\sim} \mathcal{N}(\mu, \sigma^2), \qquad n \geq 2,\; \sigma > 0 $$

Since the sample median is translation invariant, set $\mu = 0$ without loss of generality. Write

$$ M_n = \Median(X_1, \ldots, X_n) $$

For any continuous distribution with density $f$ positive at its median $\theta$, classical theory (sidak1999, serfling2009) gives

$$ \sqrt{n}\,(M_n - \theta) \xrightarrow{d} \mathcal{N}\Bigl(0, \frac{1}{4f(\theta)^2}\Bigr) $$

In the normal case $\theta = 0$ and

$$ f(0) = \frac{1}{\sigma\sqrt{2\pi}} $$

so the asymptotic variance becomes

$$ \frac{1}{4f(0)^2} = \frac{1}{4}\,\bigl(\sigma\sqrt{2\pi}\bigr)^2 = \frac{\pi\sigma^2}{2} $$

Hence

$$ \sqrt{n}\,M_n \xrightarrow{d} \mathcal{N}\Bigl(0, \frac{\pi\sigma^2}{2}\Bigr), \qquad n \to \infty $$

The sample mean has asymptotic variance $\sigma^2/n$, so the asymptotic Gaussian efficiency of the median is

$$ \eff_{\mathcal{N},\infty}(\Median) = \frac{\sigma^2/n}{\pi\sigma^2/(2n)} = \frac{2}{\pi} \approx 0.637 $$

Thus achieving the same precision as the mean under normality requires roughly $1/0.637 \approx 1.57$ times as many observations when using the median. This large efficiency loss shows why we prefer the Hodges–Lehmann $\Center$ estimator — which attains about $95.5\%$ efficiency — whenever data are roughly Gaussian but may include outliers.

Asymptotic Gaussian Efficiency of the Spread

This study shows that $\Spread$ achieves approximately $86\%$ efficiency relative to the sample standard deviation under normality.

The analysis uses U-statistic theory to derive the asymptotic distribution of $\Spread$ as a scale estimator under Gaussian data. Consider

$$ X_1, \ldots, X_n \stackrel{\mathrm{iid}}{\sim} \mathcal{N}(\mu, \sigma^2), \qquad n \geq 2,\; \sigma > 0 $$

Since $\Spread(\x) = \Median |X_i - X_j|$ is translation invariant, set $\mu = 0$ without loss of generality and write

$$ R_n = \Spread(\x) $$$$ m_0 = \sqrt{2}\,\Phi^{-1}(0.75)\,\sigma \approx 0.954\,\sigma $$

Here $m_0$ denotes the population median of $|X_i - X_j|$ when $X_i \sim \mathcal{N}(0, \sigma^2)$. Letting $D = |X_1 - X_2|$, its density is

$$ f_D(t) = \frac{1}{\sigma\sqrt{\pi}}\, \exp\Bigl(-\frac{t^2}{4\sigma^2}\Bigr), \qquad t \geq 0 $$

with $f_D(m_0) = \sigma^{-1}\pi^{-1/2}\exp(-\Phi^{-1}(0.75)^2/2)$. Treating $R_n$ as a degree-two U-quantile and applying asymptotic theory sen1963 yields

$$ \sqrt{n}\,\bigl(R_n - m_0\bigr) \xrightarrow{d} \mathcal{N}\Bigl(0, \frac{4\,\Var[\psi(X_1)]}{f_D(m_0)^2}\Bigr) $$

where

$$ \begin{aligned} \psi(x) &= \Pr\bigl\{|x - X_2| \leq m_0\bigr\} - \tfrac{1}{2}\\ &= \Phi\Bigl(\tfrac{x + m_0}{\sigma}\Bigr) - \Phi\Bigl(\tfrac{x - m_0}{\sigma}\Bigr) - \tfrac{1}{2} \end{aligned} $$

Numerical evaluation of the integral

$$ \Var[\psi(X_1)] = \int_{-\infty}^{\infty}\psi(x)^2\, \frac{e^{-x^2/(2\sigma^2)}}{\sigma\sqrt{2\pi}}\;dx $$

yields $\Var[\psi(X_1)] \approx 0.0266$. Substituting this value and $f_D(m_0)$ into the variance formula gives

$$ \Var\bigl[\sqrt{n}\,R_n\bigr] \approx 0.527\,\sigma^2 $$

Because $R_n$ is not a consistent estimator of $\sigma$, comparisons with the sample standard deviation $\StdDev(\x)$ use the rescaled statistic

$$ \widehat{\sigma}_{\Spread} = \frac{R_n}{m_0} $$

which is consistent. Dividing the variance above by the constant $m_0^2$ gives

$$ \Var\bigl[\sqrt{n}\,\widehat{\sigma}_{\Spread}\bigr] \approx 0.579\,\sigma^2 $$

The optimal Gaussian scale estimator $\StdDev(\x)$ has asymptotic variance $\sigma^2/(2n)$, so the asymptotic Gaussian efficiency of the (scaled) $\Spread$ is

$$ \eff_{\mathcal{N},\infty}(\Spread) = \frac{\sigma^2/(2n)}{0.579\,\sigma^2/n} \approx 0.864 $$

One needs roughly $1/0.864 \approx 1.16$ times as many observations to match the precision of the sample standard deviation when the data are exactly normal. In exchange, $\Spread$ inherits a $29\%$ breakdown point from its U-quantile construction, so moderate extra data provide a substantial increase in robustness.

Asymptotic Gaussian Efficiency of the Median Absolute Deviation

This study shows that the median absolute deviation (MAD) achieves only about $37\%$ efficiency relative to the sample standard deviation under normality.

The analysis derives the asymptotic distribution of the MAD under Gaussian data using classical theory for sample medians. Consider

$$ X_1, \ldots, X_n \stackrel{\mathrm{iid}}{\sim} \mathcal{N}(\mu, \sigma^2), \qquad n \geq 2,\; \sigma > 0 $$

Since both the sample median and the MAD are translation invariant, set $\mu = 0$ without loss of generality and write

$$ \MAD_n = \Median\Bigl(|X_i - \Median(\x)| : i = 1, \ldots, n\Bigr) $$

For a standard normal distribution, the population MAD equals

$$ m_0 = \Phi^{-1}(0.75)\,\sigma = c_0\,\sigma $$$$ c_0 = \Phi^{-1}(0.75) \approx 0.674 $$

Dividing the empirical MAD by this constant gives a consistent scale estimator:

$$ \widehat{\sigma}_{\MAD} = \frac{\MAD_n}{c_0} $$

To find its large-sample variance, observe that $Y_i = |X_i|$ has density

$$ g(y) = \frac{2}{\sigma\sqrt{2\pi}} \exp\Bigl(-\frac{y^2}{2\sigma^2}\Bigr), \qquad y \geq 0 $$

whose median is $m_0$. A classical result for sample medians of independent draws with continuous positive density at the median (sidak1999, serfling2009) states

$$ \sqrt{n}\bigl(\Median(Y_1, \ldots, Y_n) - m_0\bigr) \xrightarrow{d} \mathcal{N}\Bigl(0, \tfrac{1}{4g(m_0)^2}\Bigr) $$

Since

$$ g(m_0) = \frac{2}{\sigma\sqrt{2\pi}}\, \exp\Bigl(-\frac{c_0^2}{2}\Bigr) $$

the asymptotic variance of $\sqrt{n}\,\MAD_n$ is

$$ \Var\bigl[\sqrt{n}\,\MAD_n\bigr] = \frac{1}{4g(m_0)^2} = \frac{\pi\sigma^2\exp(c_0^2)}{8} $$

Scaling by $1/c_0$ gives the variance of the consistent estimator:

$$ \Var\bigl[\sqrt{n}\,\widehat{\sigma}_{\MAD}\bigr] = \frac{\pi\sigma^2\exp(c_0^2)}{8\,c_0^2} $$

The optimal Gaussian scale estimator is the sample standard deviation. It has asymptotic variance of $\sigma^2/(2n)$. The asymptotic Gaussian efficiency of the (scaled) MAD is therefore

$$ \eff_{\mathcal{N},\infty}(\MAD) = \frac{\sigma^2/(2n)}{\pi\sigma^2\exp(c_0^2)/(8c_0^2n)} = \frac{4c_0^2}{\pi\,\exp(c_0^2)} $$

This gives the result:

$$ \eff_{\mathcal{N},\infty}(\MAD) \approx 0.367\,523 $$

Achieving the same precision as the sample standard deviation under normality requires roughly $1/0.368 \approx 2.7$ times as many observations when using the MAD.

Finite-Sample Efficiency of Central Tendency Estimators

This study presents finite-sample efficiency values for $\Center$ and shows how it performs better than $\Median$ across small and medium sample sizes.

The previous studies established asymptotic efficiency values — the limiting behavior as sample size approaches infinity. For the Gaussian distribution, these asymptotic values are:

Asymptotic theory provides excellent approximations for large samples but may be inaccurate for small $n$. Finite-sample efficiency captures the actual precision when working with limited data.

Efficiency and Sample Size Requirements

Efficiency quantifies the variance ratio between estimators. For two estimators $T_1$ and $T_2$ applied to the same distribution:

$$ \eff(T_1 \text{ relative to } T_2) = \frac{\Var[T_2]}{\Var[T_1]} $$

This ratio directly translates to sample size requirements. An estimator with $80\%$ efficiency needs $100/80 = 1.25$ times as many observations to achieve the same precision as the reference estimator. The $\Median$ with its $63.7\%$ asymptotic efficiency requires roughly $1.57$ times more data than the $\Mean$ under normality.

Monte Carlo Estimation of Finite-Sample Efficiency

Numerical simulation provides exact efficiency values for any sample size. The procedure follows these steps:

  1. Generate samples: Draw $m$ independent samples of size $n$ from the standard normal distribution
  2. Calculate estimators: Compute both estimators for each sample
  3. Measure dispersion: Calculate the sample variance of the $m$ estimator values
  4. Compute efficiency: Take the variance ratio

The simulation must balance computational cost against precision. Larger $m$ reduces Monte Carlo error but increases computation time. For efficiency estimation, $m = 10^6$ iterations achieve enough precision.

Finite-Sample Results

The simulation reveals how efficiency evolves from small to moderate sample sizes.

The figure below shows the Gaussian efficiency curves for $n \in \{3, \ldots, 100\}$ based on $m = 10^6$ Monte Carlo iterations (dotted lines show asymptotic values):

Key Observations

  1. Small sample behavior: For $n = 3$, $\Center$ achieves $97.9\%$ efficiency while $\Median$ drops to $74.3\%$. Even at extreme small samples, $\Center$ maintains above $91\%$ efficiency throughout.

  2. Convergence patterns: The $\Center$ estimator reaches $94\%$ efficiency by $n = 15$ and stabilizes above $95\%$ for $n \geq 50$. The $\Median$ oscillates between $63.5\%$ and $68\%$ across all sample sizes, never approaching the efficiency of $\Center$.

  3. Practical advantage: For typical applications ($n = 20$ to $50$), $\Center$ maintains $94-95\%$ efficiency. This represents only a $5-6\%$ penalty compared to $\Mean$, while $\Median$ suffers a $35-37\%$ penalty.

The toolkit’s $\Center$ estimator performs much better than $\Median$ while sacrificing minimal efficiency compared to the non-robust $\Mean$.

Finite-Sample Efficiency of Dispersion Estimators

This study presents finite-sample efficiency values for $\Spread$ and demonstrates its consistent superiority over the standard deviation $\StdDev$ and the median absolute deviation $\MAD$ across small and medium sample sizes.

The previous studies established asymptotic efficiency values for dispersion estimators under the Gaussian distribution. These asymptotic values are:

The asymptotic values provide excellent approximations for large samples but may not accurately reflect performance with limited data. Understanding actual efficiency at practical sample sizes guides estimator selection from the toolkit.

Efficiency Measurement for Dispersion Estimators

Dispersion estimators face a variance-bias trade-off: different estimators have different expected values under the same distribution. To compare their variability fairly, the simulation normalizes each estimator by its expected value. This normalization eliminates bias differences and focuses purely on variance comparison.

The procedure follows these steps:

  1. Generate samples: Draw $m$ independent samples of size $n$ from the standard normal distribution
  2. Calculate estimators: Compute $\StdDev$, $\Spread$, and $\MAD$ for each sample
  3. Calculate normalized variance: for each set of estimations, calculate the variance and divide by the mean value to align estimator biases
  4. Compute efficiency: Take the variance ratio relative to $\StdDev$

This approach ensures fair comparison by measuring how much each estimator varies around its own expected value. The simulation uses $m = 10^6$ iterations to achieve sufficient precision.

Results and Analysis

The simulation covers sample sizes $n \in \{3, \ldots, 100\}$ with efficiency computed relative to standard deviation.

The below figure shows the Gaussian efficiency curves based on $10^6$ Monte Carlo iterations (dotted lines show asymptotic values):

Key Observations

  1. Superior efficiency: $\Spread$ consistently outperforms $\MAD$ by a factor of two across all sample sizes. At $n = 20$, $\Spread$ achieves $81.4\%$ efficiency while $\MAD$ reaches only $39.0\%$.

  2. Practical implications: For typical sample sizes ($n = 20$ to $50$), $\Spread$ maintains $81-84\%$ efficiency. This $16-19\%$ penalty compared to $\StdDev$ represents a reasonable trade-off for robustness.

  3. Small sample behavior: $\Spread$ shows a characteristic dip for $n = 5-8$ (dropping to $74\%$) before recovering. Even at its worst, $\Spread$ remains twice as efficient as $\MAD$.

$\Spread$ from the toolkit provides a substantial efficiency advantage over $\MAD$ while maintaining reasonable performance compared to the non-robust standard deviation. This efficiency advantage, combined with its robustness properties, makes $\Spread$ the preferred choice for dispersion estimation in practical applications.


  1. Also known as the Hodges–Lehmann location estimator, see hodges1963, sen1963 ↩︎

  2. Also known as the Shamos scale estimator, see shamos1976 ↩︎

  3. Also known as sample median ↩︎

  4. Also known as order statistics ↩︎

  5. Also known as the Hodges–Lehmann shift estimator ↩︎

  6. Inspired by the Hodges–Lehmann estimator ↩︎

  7. A robust alternative to traditional effect size measures like Cohen’s $d$ ↩︎

  8. See https://github.com/easystats/bayestestR/discussions/250 ↩︎