Computes two statistics that survive outliers: the robust standard deviation by
the Q method and the robust mean by the Hampel estimator, from a table of
laboratory results. It exists for the case ISO 13528 has in mind — proficiency
testing and interlaboratory comparison with a handful of participants, where one
laboratory with a broken instrument can drag an ordinary mean far enough to make
everybody else look wrong. Both statistics are used as the assigned value and the
standard deviation for proficiency assessment in such studies.
How to use
- Enter one laboratory per line in the data box.
- Separate the values of one laboratory with spaces, commas, semicolons or tabs.
A dot is the decimal separator.
- Laboratories may carry a different number of values; blank lines and empty or
NaN cells are ignored.
- Run. The panel returns the robust mean, the robust standard deviation, and the
counts used.
At least two non-empty lines are required. A single laboratory has no between-lab
structure to estimate.
Q method (robust standard deviation). For p laboratories with nᵢ values
each, form every pairwise difference between values of different laboratories —
n_pairs = Σᵢ<ⱼ nᵢ·nⱼ differences. Sort them and compute the empirical
distribution G of the differences. Then
s* = G⁻¹(0.25 + 0.75 · H1(0)) / (√2 · Φ⁻¹(0.625 + 0.375 · H1(0)))
where H1(0) = G(0) is the empirical distribution function of the differences
evaluated at zero, and Φ⁻¹ is the inverse standard normal CDF. Interpolation is
linear in the empirical quantiles, clamped at both ends. The formula is the
classical Q/Hampel construction; it estimates the standard deviation without ever
computing a mean, so a gross error inflates the difference list but the median-based
quantile positions barely move.
Hampel estimator (robust mean). Using s* above, form the Hampel ψ function
ψ(q) = q for |q| ≤ 1, 1.5·sign(q) for 1 < |q| ≤ 2,
(4.5 − |q|)·sign(q) for 2 < |q| < 3, and 0 beyond 3,
applied to q = (xᵢ − x̄)/s* for each laboratory mean. The estimator is the value
x̄ that solves Σ ψ = 0. The implementation builds the interpolation nodes and
solves piecewise, then picks the solution nearest the median of the laboratory
means. If no sign change exists, it falls back to that median and says so.
| Requirement |
Behaviour |
| At least 2 laboratories |
A single line is rejected |
| Finite numbers only |
inf is rejected; empty and NaN cells are skipped |
| Up to 2 000 000 pairwise differences |
Larger tables stop with an explicit error |
| Not too many identical values |
If 0.625 + 0.375·H1(0) > 1, the Q method is undefined |
| Robust SD may be 0 |
Almost all values identical: the mean nearest the median is used, with a warning |
The difference cap exists because the Q method is O(n²) in the value count: doubling
the table quadruples the work.
FAQ
Why not use the ordinary mean and standard deviation? Because with five to ten
laboratories a single outlier has enormous leverage: the mean moves toward it and
the standard deviation inflates, so a systematically wrong laboratory can be judged
"acceptable" while correct ones fall outside ±2s. The Q/Hampel pair resists that.
What does the result mean numerically? The robust mean is the consensus value of
the study, and the robust standard deviation is the between-laboratory spread that
proficiency assessment uses. Feed them into x_pt and s_pt of the interlaboratory
comparison tool to obtain E_n scores per laboratory.
Why did it warn that the robust SD is 0? Nearly all results were identical, so
the differences carry no spread. The tool then reports the laboratory mean nearest
the median. That is a data problem, not a calculation problem: identical results at
instrument resolution usually mean the resolution is too coarse for the study.
Can it handle laboratories with different numbers of measurements? Yes. Each
laboratory is reduced to its mean for the Hampel step, and the Q method uses all
pairwise differences, which tolerates unequal counts.
Common mistakes
- Using a comma as the decimal separator. In Indonesian-style numbers
41,41
splits into two values and the laboratory gets two data points. Write 41.41.
- Mixing units between laboratories. The Q method has no idea that one line is
in mΩ and the rest in Ω; it will simply report a large robust SD.
- Dropping outliers before running it. The whole point is to let the estimator
handle them. Removing data first inflates the apparent agreement of the group.
- Reusing one laboratory's values in the between-repeat spread. The Q method
estimates between-laboratory dispersion; repeated measurements from one
instrument belong in a different statistic.