Skip to content

Qn and Sn scale estimators

Calculate robust pairwise scale using Qn and Sn, distinguish raw from normal-calibrated estimates, and handle median conventions, ties and breakdown limits.

Qn and Sn are robust estimators of scale built from pairwise absolute differences between observations. They measure spread without first estimating a centre. In quant work, they can provide a baseline scale for return or residual diagnostics when a few extreme observations would dominate the standard deviation. That resistance does not establish that a market jump is an error: a genuine loss still belongs in the risk analysis.

Both were introduced by Rousseeuw and Croux as alternatives to the median absolute deviation, or MAD. The distinction is structural. MAD measures distances from the sample median; Qn and Sn compare observations with one another. A high breakdown point describes resistance to contamination, rather than accuracy for every financial distribution.

Qn selects one ordered pairwise distance

For n≥2n\ge2 finite real observations, collect the (n2)\binom{n}{2} distances ∣xi−xj∣\lvert x_i-x_j\rvert with i<ji<j, retaining repeated distances. Sort them and define

h=⌊n2⌋+1,k=(h2),Qraw={∣xi−xj∣:i<j}(k).h=\left\lfloor\frac n2\right\rfloor+1, \qquad k=\binom h2, \qquad Q_{\mathrm{raw}}=\{\lvert x_i-x_j\rvert:i<j\}_{(k)}.
The subscript (k)(k) means the kkth smallest distance, using one-based ranks. This rank approaches the lower quartile of the pairwise distances as the sample grows. It is not an instruction to call an arbitrary interpolated 25th-percentile routine, particularly in a small sample. The robustbase Qn documentation states this rank explicitly.

Consider the fictional observations

x=(0,1,2,3,100).x=(0,1,2,3,100).

Here h=3h=3 and k=3k=3. The ten sorted distances are

1,1,1,2,2,3,97,98,99,100.1,1,1,2,2,3,97,98,99,100.

The third smallest is 11, so Qraw=1Q_{\mathrm{raw}}=1. The four distances involving 100 lie at the upper end and do not determine the selected rank.

Sn takes a median of within-observation medians

For odd nn, first take the median distance from each observation to all nn observations, including itself. Then take the median of those nn answers:
Sraw=median⁡i{median⁡j∣xi−xj∣}.S_{\mathrm{raw}} =\operatorname{median}_i\left\{ \operatorname{median}_j\lvert x_i-x_j\rvert \right\}.

For the same five observations:

ObservationSorted distances, including selfInner median
00, 1, 2, 3, 1002
10, 1, 1, 2, 991
20, 1, 1, 2, 981
30, 1, 2, 3, 972
1000, 97, 98, 99, 10098

The median of 2,1,1,2,982,1,1,2,98 is 22, giving Sraw=2S_{\mathrm{raw}}=2.

For even nn, the convention matters. The usual Rousseeuw–Croux definition, also used in the robustbase implementation, is outer low median of inner high medians. For mm ordered values, the low median has rank ⌊(m+1)/2⌋\lfloor(m+1)/2\rfloor and the high median has rank ⌊m/2⌋+1\lfloor m/2\rfloor+1. Keep the self-distances when using this definition. Averaging the two middle values at both stages defines a different statistic. With five observations, all these median conventions agree.
For fictional data 0, 1, 2, 3, 100, Qn selects the third of ten distances, giving raw Q equal to 1. Sn uses row medians 2, 1, 1, 2, 98 and gives raw S equal to 2. Neither result includes calibration.
For fictional data 0, 1, 2, 3, 100, Qn selects the third of ten distances, giving raw Q equal to 1. Sn uses row medians 2, 1, 1, 2, 98 and gives raw S equal to 2. Neither result includes calibration.
Two selections from the same pairwise distances. Moving the last observation from 100 to 1,000 leaves both raw answers unchanged; the sample range rises from 100 to 1,000.

Raw spread and calibrated scale are different outputs

Normal-model calibration writes the estimators as

Qn=dnaQQraw,Sn=cnaSSraw,Q_n=d_n a_Q Q_{\mathrm{raw}}, \qquad S_n=c_n a_S S_{\mathrm{raw}},
where aQ,aSa_Q,a_S are asymptotic consistency constants and dn,cnd_n,c_n are optional finite-sample bias corrections. Consistency here targets the standard deviation σ\sigma of an i.i.d. normal model, not variance σ2\sigma^2, as the statsmodels Qn documentation explicitly specifies.

The corrected Qn constant is

aQ=12 Φ−1(5/8)≈2.219144466,a_Q=\frac{1}{\sqrt{2}\,\Phi^{-1}(5/8)} \approx2.219144466,
with Φ\Phi the standard normal CDF. The historical value 2.2219 contains a small error; robustbase documents the correction and uses the rounded constant 2.21914. For Sn, aS≈1.1926a_S\approx1.1926. Before finite-sample correction, these give about 2.21914 and 2.3852 for our example. They are not the raw values 1 and 2, and neither pair should be presented as a library's default corrected output. See the checked Qn and Sn documentation for their defaults.
Finite-sample corrections depend on sample size and the chosen implementation. Normal calibration does not make the estimator equal to standard deviation for an arbitrary skewed or heavy-tailed distribution. Akinshin's finite-sample study distinguishes these calibration factors from their large-sample limits.

What the robust number leaves out

For our original sample, the unscaled MAD is 1, the range is 100, the sample variance is 1,941.7, and the sample standard deviation is about 44.0647, using divisor n−1n-1. The agreement between raw Qn and raw MAD is a coincidence of this sample. Variance has squared units; the other measures retain the observations' units. A range uses only the endpoints, while these robust scales select central features of the distances.

Both Qn and Sn are translation invariant and scale equivariant: adding a constant leaves them unchanged; multiplying the observations by bb multiplies the estimate by ∣b∣\lvert b\rvert. If observations are returns in percentage points, the resulting scale is also in percentage points.

Their familiar 50% breakdown description is a large-sample replacement-contamination statement, with finite-sample qualifications and an initially nondegenerate sample. Breakdown of a scale includes both explosion to infinity and collapse to zero. It is not a guarantee of small bias below 50% contamination. With just five observations, two replacements can create a triple tie and collapse both estimates to zero. Indeed, the separate toy sample (0,0,0,1,2)(0,0,0,1,2) already gives Qraw=Sraw=0Q_{\mathrm{raw}}=S_{\mathrm{raw}}=0. A zero denominator can therefore arise from rounding or repeated prices even when not every observation is equal.

For return diagnostics, report the convention and inspect the observations behind it. Robust scale can stabilise a reference level while extreme losses remain economically important. It does not by itself estimate tail-loss probabilities, resolve serial dependence, or justify a square-root-of-time annualisation.

For the ordinary sample median, variance and standard-deviation baseline used in this comparison, see Basic Statistics and Regression, available with a free signed-in account.

Practice: the even-sample convention

For (0,1,10,11)(0,1,10,11), compute raw Sn using inner high medians, including self-distances, and the outer low median. Would averaging both middle values at each stage give the same answer?
Answer. The inner high medians are 10,9,9,1010,9,9,10. Their outer low median is 99. Averaging both middle distances within each row instead gives 5.5,5,5,5.55.5,5,5,5.5; averaging the middle two of those gives 5.255.25. That second calculation is a different statistic, not a finite-sample correction to Sn.

Sources

Last updated
  • robust statistics
  • scale estimation
  • qn
  • sn
  • pairwise distances
← Back to the glossaryBack to top ↑