ShiftBounds ShiftBounds ( x , y , m i s r a t e ) = [ z ( k left ) , z ( k right ) ] \operatorname{ShiftBounds}(\mathbf{x}, \mathbf{y}, \mathrm{misrate}) = [z_{(k_{\text{left}})}, z_{(k_{\text{right}})}] ShiftBounds ( x , y , misrate ) = [ z ( k left ) , z ( k right ) ]
where z = x i − y j \mathbf{z} = { x_i - y_j } z = x i − y j (sorted), k left = ⌊ PairwiseMargin 2 ⌋ + 1 k_{\text{left}} = \lfloor \frac{\operatorname{PairwiseMargin}}{2} \rfloor + 1 k left = ⌊ 2 PairwiseMargin ⌋ + 1 , k right = n m − ⌊ PairwiseMargin 2 ⌋ k_{\text{right}} = n m - \lfloor \frac{\operatorname{PairwiseMargin}}{2} \rfloor k right = nm − ⌊ 2 PairwiseMargin ⌋
Robust bounds on Shift ( x , y ) \operatorname{Shift}(\mathbf{x}, \mathbf{y}) Shift ( x , y ) with specified coverage.
Also known as — distribution-free confidence interval for Hodges-Lehmann
Interpretation — m i s r a t e \mathrm{misrate} misrate is probability that true shift falls outside bounds
Domain — any real numbers, m i s r a t e ≥ 2 ( n + m n ) \mathrm{misrate} \geq \frac{2}{\binom{n+m}{n}} misrate ≥ ( n n + m ) 2
Unit — same as measurements
Note — assumes weak continuity (ties from measurement resolution are tolerated but may yield conservative bounds)
Properties
Shift invariance ShiftBounds ( x + k , y + k , m i s r a t e ) = ShiftBounds ( x , y , m i s r a t e ) \operatorname{ShiftBounds}(\mathbf{x} + k, \mathbf{y} + k, \mathrm{misrate}) = \operatorname{ShiftBounds}(\mathbf{x}, \mathbf{y}, \mathrm{misrate}) ShiftBounds ( x + k , y + k , misrate ) = ShiftBounds ( x , y , misrate )
Scale equivariance ShiftBounds ( k ⋅ x , k ⋅ y , m i s r a t e ) = k ⋅ ShiftBounds ( x , y , m i s r a t e ) \operatorname{ShiftBounds}(k \cdot \mathbf{x}, k \cdot \mathbf{y}, \mathrm{misrate}) = k \cdot \operatorname{ShiftBounds}(\mathbf{x}, \mathbf{y}, \mathrm{misrate}) ShiftBounds ( k ⋅ x , k ⋅ y , misrate ) = k ⋅ ShiftBounds ( x , y , misrate )
Example
ShiftBounds([1..30], [21..50], 1e-4) = [-30, -10] where Shift = -20
Bounds fail to cover true shift with probability ≈ m i s r a t e \approx \mathrm{misrate} ≈ misrate
ShiftBounds \operatorname{ShiftBounds} ShiftBounds provides not just the estimated shift but also the uncertainty of that estimate. The function returns an interval of plausible shift values given the data. Set m i s r a t e \mathrm{misrate} misrate to control how often the bounds might fail to contain the true shift: use 10 − 3 10^{-3} 1 0 − 3 for everyday analysis or 10 − 6 10^{-6} 1 0 − 6 for critical decisions where errors are costly. These bounds require no assumptions about your data distribution, so they remain valid for any continuous measurements. If the bounds exclude zero, that suggests a reliable difference between the two groups.
Algorithm
The ShiftBounds \operatorname{ShiftBounds} ShiftBounds estimator constructs distribution-free bounds on Shift ( x , y ) \operatorname{Shift}(\mathbf{x}, \mathbf{y}) Shift ( x , y ) by selecting specific order statistics from the pairwise differences.
Given samples x = ( x 1 , … , x n ) \mathbf{x} = (x_1, \ldots, x_n) x = ( x 1 , … , x n ) and y = ( y 1 , … , y m ) \mathbf{y} = (y_1, \ldots, y_m) y = ( y 1 , … , y m ) , the algorithm proceeds as follows:
Compute the margin Call PairwiseMargin ( n , m , m i s r a t e ) \operatorname{PairwiseMargin}(n, m, \mathrm{misrate}) PairwiseMargin ( n , m , misrate ) (see PairwiseMargin ) to determine how many extreme pairwise differences to exclude from each tail.
Determine quantile ranks From the margin M M M , compute k left = ⌊ M 2 ⌋ + 1 k_{\text{left}} = \lfloor \frac{M}{2} \rfloor + 1 k left = ⌊ 2 M ⌋ + 1 and k right = n m − ⌊ M 2 ⌋ k_{\text{right}} = n m - \lfloor \frac{M}{2} \rfloor k right = nm − ⌊ 2 M ⌋ . These are the ranks of the order statistics that form the bounds.
Compute quantiles via Shift Use the Shift algorithm to compute the k left k_{\text{left}} k left -th and k right k_{\text{right}} k right -th order statistics of all n m n m nm pairwise differences x i − y j x_i - y_j x i − y j . The Shift algorithms value-space binary search finds these quantiles in O ( ( n + m ) log L ) O((n + m) \log L) O (( n + m ) log L ) time without materializing all differences.
Return bounds Return [ z ( k left ) , z ( k right ) ] [z_{(k_{\text{left}})}, z_{(k_{\text{right}})}] [ z ( k left ) , z ( k right ) ] .
The PairwiseMargin \operatorname{PairwiseMargin} PairwiseMargin function encodes the statistical theory: it determines which order statistics provide bounds with coverage 1 − m i s r a t e 1 - \mathrm{misrate} 1 − misrate . The Shift \operatorname{Shift} Shift algorithm provides the computational machinery: it extracts those specific order statistics efficiently from the implicit matrix of pairwise differences.
Tests
ShiftBounds ( x , y , m i s r a t e ) = [ z ( k left ) , z ( k right ) ] \operatorname{ShiftBounds}(\mathbf{x}, \mathbf{y}, \mathrm{misrate}) = [z_{(k_{\text{left}})}, z_{(k_{\text{right}})}] ShiftBounds ( x , y , misrate ) = [ z ( k left ) , z ( k right ) ]
where
z = x i − y j 1 ≤ i ≤ n , 1 ≤ j ≤ m ( sorted ) \mathbf{z} = { x_i - y_j }_{1 \leq i \leq n, 1 \leq j \leq m} \quad (\text{sorted}) z = x i − y j 1 ≤ i ≤ n , 1 ≤ j ≤ m ( sorted )
k left = ⌊ PairwiseMargin ( n , m , m i s r a t e ) 2 ⌋ + 1 k_{\text{left}} = \lfloor \frac{\operatorname{PairwiseMargin}(n, m, \mathrm{misrate})}{2} \rfloor + 1 k left = ⌊ 2 PairwiseMargin ( n , m , misrate ) ⌋ + 1
k right = n m − ⌊ PairwiseMargin ( n , m , m i s r a t e ) 2 ⌋ k_{\text{right}} = n m - \lfloor \frac{\operatorname{PairwiseMargin}(n, m, \mathrm{misrate})}{2} \rfloor k right = nm − ⌊ 2 PairwiseMargin ( n , m , misrate ) ⌋
The ShiftBounds \operatorname{ShiftBounds} ShiftBounds test suite contains 61 correctness test cases (3 demo + 9 natural + 6 property + 10 edge + 9 additive + 4 uniform + 5 misrate + 15 unsorted). Since ShiftBounds \operatorname{ShiftBounds} ShiftBounds returns bounds rather than a point estimate, tests validate that the bounds contain Shift ( x , y ) \operatorname{Shift}(\mathbf{x}, \mathbf{y}) Shift ( x , y ) and satisfy equivariance properties. Each test case output is a JSON object with lower and upper fields representing the interval bounds. The domain constraint m i s r a t e ≥ 2 ( n + m n ) \mathrm{misrate} \geq \frac{2}{\binom{n+m}{n}} misrate ≥ ( n n + m ) 2 is enforced; inputs violating this return a domain error.
Demo examples (n = m = 5 n = m = 5 n = m = 5 ) — from manual introduction, validating basic bounds:
demo-1: x = ( 1 , 2 , 3 , 4 , 5 ) \mathbf{x} = (1, 2, 3, 4, 5) x = ( 1 , 2 , 3 , 4 , 5 ) , y = ( 3 , 4 , 5 , 6 , 7 ) \mathbf{y} = (3, 4, 5, 6, 7) y = ( 3 , 4 , 5 , 6 , 7 ) , m i s r a t e = 0.05 \mathrm{misrate} = 0.05 misrate = 0.05 , expected output: [ − 4 , 0 ] [-4, 0] [ − 4 , 0 ]
demo-2: x = ( 1 , 2 , 3 , 4 , 5 ) \mathbf{x} = (1, 2, 3, 4, 5) x = ( 1 , 2 , 3 , 4 , 5 ) , y = ( 3 , 4 , 5 , 6 , 7 ) \mathbf{y} = (3, 4, 5, 6, 7) y = ( 3 , 4 , 5 , 6 , 7 ) , m i s r a t e = 0.01 \mathrm{misrate} = 0.01 misrate = 0.01 , expected output: [ − 5 , 1 ] [-5, 1] [ − 5 , 1 ]
demo-3: x = ( 3 , 4 , 5 , 6 , 7 ) \mathbf{x} = (3, 4, 5, 6, 7) x = ( 3 , 4 , 5 , 6 , 7 ) , y = ( 3 , 4 , 5 , 6 , 7 ) \mathbf{y} = (3, 4, 5, 6, 7) y = ( 3 , 4 , 5 , 6 , 7 ) , m i s r a t e = 0.05 \mathrm{misrate} = 0.05 misrate = 0.05 , expected output: bounds containing 0 0 0 (identity case)
These cases illustrate how tighter misrates produce wider bounds and validate the identity property where identical samples yield bounds containing zero.
Natural sequences ([ n , m ] i n 5 , 8 , 10 × 5 , 8 , 10 [n, m] in {5, 8, 10} \times {5, 8, 10} [ n , m ] in 5 , 8 , 10 × 5 , 8 , 10 , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 ) — 9 combinations:
natural-5-5: x = ( 1 , … , 5 ) \mathbf{x} = (1, \ldots, 5) x = ( 1 , … , 5 ) , y = ( 1 , … , 5 ) \mathbf{y} = (1, \ldots, 5) y = ( 1 , … , 5 ) , expected bounds containing 0 0 0
natural-5-8: x = ( 1 , … , 5 ) \mathbf{x} = (1, \ldots, 5) x = ( 1 , … , 5 ) , y = ( 1 , … , 8 ) \mathbf{y} = (1, \ldots, 8) y = ( 1 , … , 8 )
natural-5-10: x = ( 1 , … , 5 ) \mathbf{x} = (1, \ldots, 5) x = ( 1 , … , 5 ) , y = ( 1 , … , 10 ) \mathbf{y} = (1, \ldots, 10) y = ( 1 , … , 10 )
natural-8-5: x = ( 1 , … , 8 ) \mathbf{x} = (1, \ldots, 8) x = ( 1 , … , 8 ) , y = ( 1 , … , 5 ) \mathbf{y} = (1, \ldots, 5) y = ( 1 , … , 5 )
natural-8-8: x = ( 1 , … , 8 ) \mathbf{x} = (1, \ldots, 8) x = ( 1 , … , 8 ) , y = ( 1 , … , 8 ) \mathbf{y} = (1, \ldots, 8) y = ( 1 , … , 8 ) , expected bounds containing 0 0 0
natural-8-10: x = ( 1 , … , 8 ) \mathbf{x} = (1, \ldots, 8) x = ( 1 , … , 8 ) , y = ( 1 , … , 10 ) \mathbf{y} = (1, \ldots, 10) y = ( 1 , … , 10 )
natural-10-5: x = ( 1 , … , 10 ) \mathbf{x} = (1, \ldots, 10) x = ( 1 , … , 10 ) , y = ( 1 , … , 5 ) \mathbf{y} = (1, \ldots, 5) y = ( 1 , … , 5 )
natural-10-8: x = ( 1 , … , 10 ) \mathbf{x} = (1, \ldots, 10) x = ( 1 , … , 10 ) , y = ( 1 , … , 8 ) \mathbf{y} = (1, \ldots, 8) y = ( 1 , … , 8 )
natural-10-10: x = ( 1 , … , 10 ) \mathbf{x} = (1, \ldots, 10) x = ( 1 , … , 10 ) , y = ( 1 , … , 10 ) \mathbf{y} = (1, \ldots, 10) y = ( 1 , … , 10 ) , expected bounds containing 0 0 0
These sizes are chosen to satisfy m i s r a t e ≥ 2 ( n + m n ) \mathrm{misrate} \geq \frac{2}{\binom{n+m}{n}} misrate ≥ ( n n + m ) 2 for all combinations.
Property validation (n = m = 10 n = m = 10 n = m = 10 , m i s r a t e = 10 − 3 \mathrm{misrate} = 10^{-3} misrate = 1 0 − 3 ) — 6 tests:
property-identity: x = ( 0 , 2 , 4 , … , 18 ) \mathbf{x} = (0, 2, 4, \ldots, 18) x = ( 0 , 2 , 4 , … , 18 ) , y = ( 0 , 2 , 4 , … , 18 ) \mathbf{y} = (0, 2, 4, \ldots, 18) y = ( 0 , 2 , 4 , … , 18 ) , bounds must contain 0 0 0
property-location-shift: x = ( 7 , 9 , 11 , … , 25 ) \mathbf{x} = (7, 9, 11, \ldots, 25) x = ( 7 , 9 , 11 , … , 25 ) , y = ( 13 , 15 , 17 , … , 31 ) \mathbf{y} = (13, 15, 17, \ldots, 31) y = ( 13 , 15 , 17 , … , 31 )
Must produce same bounds as base case (location invariance)
property-scale-2x: x = ( 2 , 4 , 6 , … , 20 ) \mathbf{x} = (2, 4, 6, \ldots, 20) x = ( 2 , 4 , 6 , … , 20 ) , y = ( 6 , 8 , 10 , … , 24 ) \mathbf{y} = (6, 8, 10, \ldots, 24) y = ( 6 , 8 , 10 , … , 24 )
Bounds must be 2× the base case bounds (scale equivariance)
property-antisymmetry: x = ( 3 , 4 , … , 12 ) \mathbf{x} = (3, 4, \ldots, 12) x = ( 3 , 4 , … , 12 ) , y = ( 1 , 2 , … , 10 ) \mathbf{y} = (1, 2, \ldots, 10) y = ( 1 , 2 , … , 10 )
Bounds must be negated: if original is [ a , b ] [a, b] [ a , b ] , this yields [ − b , − a ] [-b, -a] [ − b , − a ]
property-negative: x = ( − 10 , − 9 , … , − 1 ) \mathbf{x} = (-10, -9, \ldots, -1) x = ( − 10 , − 9 , … , − 1 ) , y = ( − 12 , − 11 , … , − 3 ) \mathbf{y} = (-12, -11, \ldots, -3) y = ( − 12 , − 11 , … , − 3 )
Validates sign handling with all negative values
property-mixed-signs: x = ( − 4 , − 3 , … , 5 ) \mathbf{x} = (-4, -3, \ldots, 5) x = ( − 4 , − 3 , … , 5 ) , y = ( − 3 , − 2 , … , 6 ) \mathbf{y} = (-3, -2, \ldots, 6) y = ( − 3 , − 2 , … , 6 )
Validates bounds crossing zero with mixed-sign samples
Edge cases — boundary conditions and extreme scenarios (10 tests):
edge-min-samples: x = ( 1 , 2 , 3 , 4 , 5 ) \mathbf{x} = (1, 2, 3, 4, 5) x = ( 1 , 2 , 3 , 4 , 5 ) , y = ( 6 , 7 , 8 , 9 , 10 ) \mathbf{y} = (6, 7, 8, 9, 10) y = ( 6 , 7 , 8 , 9 , 10 ) , m i s r a t e = 0.05 \mathrm{misrate} = 0.05 misrate = 0.05
edge-permissive-misrate: x = ( 1 , 2 , 3 , 4 , 5 ) \mathbf{x} = (1, 2, 3, 4, 5) x = ( 1 , 2 , 3 , 4 , 5 ) , y = ( 3 , 4 , 5 , 6 , 7 ) \mathbf{y} = (3, 4, 5, 6, 7) y = ( 3 , 4 , 5 , 6 , 7 ) , m i s r a t e = 0.5 \mathrm{misrate} = 0.5 misrate = 0.5 (very wide bounds)
edge-strict-misrate: n = m = 20 n = m = 20 n = m = 20 , m i s r a t e = 10 − 6 \mathrm{misrate} = 10^{-6} misrate = 1 0 − 6 (very narrow bounds)
edge-zero-shift: n = m = 10 n = m = 10 n = m = 10 , all values = 5 = 5 = 5 , m i s r a t e = 10 − 3 \mathrm{misrate} = 10^{-3} misrate = 1 0 − 3 (bounds around 0)
edge-asymmetric-3-100: n = 3 n = 3 n = 3 , m = 100 m = 100 m = 100 , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (extreme size difference)
edge-asymmetric-5-50: n = 5 n = 5 n = 5 , m = 50 m = 50 m = 50 , m i s r a t e = 10 − 3 \mathrm{misrate} = 10^{-3} misrate = 1 0 − 3 (highly unbalanced)
edge-duplicates: x = ( 3 , 3 , 3 , 3 , 3 ) \mathbf{x} = (3, 3, 3, 3, 3) x = ( 3 , 3 , 3 , 3 , 3 ) , y = ( 5 , 5 , 5 , 5 , 5 ) \mathbf{y} = (5, 5, 5, 5, 5) y = ( 5 , 5 , 5 , 5 , 5 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (all duplicates, bounds around 2)
edge-wide-range: n = m = 10 n = m = 10 n = m = 10 , values spanning 10 − 3 10^{-3} 1 0 − 3 to 10 8 10^8 1 0 8 , m i s r a t e = 10 − 3 \mathrm{misrate} = 10^{-3} misrate = 1 0 − 3 (extreme value range)
edge-tiny-values: n = m = 10 n = m = 10 n = m = 10 , values ≈ 10 − 8 \approx 10^{-8} ≈ 1 0 − 8 , m i s r a t e = 10 − 3 \mathrm{misrate} = 10^{-3} misrate = 1 0 − 3 (numerical precision)
edge-large-values: n = m = 10 n = m = 10 n = m = 10 , values ≈ 10 8 \approx 10^8 ≈ 1 0 8 , m i s r a t e = 10 − 3 \mathrm{misrate} = 10^{-3} misrate = 1 0 − 3 (large magnitude)
These edge cases stress-test boundary conditions, numerical stability, and the margin calculation with extreme parameters.
Additive distribution ([ n , m ] i n 10 , 30 , 50 × 10 , 30 , 50 [n, m] in {10, 30, 50} \times {10, 30, 50} [ n , m ] in 10 , 30 , 50 × 10 , 30 , 50 , m i s r a t e = 10 − 3 \mathrm{misrate} = 10^{-3} misrate = 1 0 − 3 ) — 9 combinations with Additive ‾ ( 10 , 1 ) \underline{\operatorname{Additive}}(10, 1) Additive ( 10 , 1 ) :
additive-10-10, additive-10-30, additive-10-50
additive-30-10, additive-30-30, additive-30-50
additive-50-10, additive-50-30, additive-50-50
Random generation: x \mathbf{x} x uses seed 0, y \mathbf{y} y uses seed 1
These fuzzy tests validate that bounds properly encompass the shift estimate for realistic normally-distributed data at various sample sizes.
Uniform distribution ([ n , m ] i n 10 , 100 × 10 , 100 [n, m] in {10, 100} \times {10, 100} [ n , m ] in 10 , 100 × 10 , 100 , m i s r a t e = 10 − 4 \mathrm{misrate} = 10^{-4} misrate = 1 0 − 4 ) — 4 combinations with Uniform ‾ ( 0 , 1 ) \underline{\operatorname{Uniform}}(0, 1) Uniform ( 0 , 1 ) :
uniform-10-10, uniform-10-100, uniform-100-10, uniform-100-100
Random generation: x \mathbf{x} x uses seed 2, y \mathbf{y} y uses seed 3
The asymmetric size combinations are particularly important for testing margin calculation with unbalanced samples.
Misrate variation (n = m = 20 n = m = 20 n = m = 20 , x = ( 0 , 2 , 4 , … , 38 ) \mathbf{x} = (0, 2, 4, \ldots, 38) x = ( 0 , 2 , 4 , … , 38 ) , y = ( 10 , 12 , 14 , … , 48 ) \mathbf{y} = (10, 12, 14, \ldots, 48) y = ( 10 , 12 , 14 , … , 48 ) ) — 5 tests with varying misrates:
misrate-1e-2: m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2
misrate-1e-3: m i s r a t e = 10 − 3 \mathrm{misrate} = 10^{-3} misrate = 1 0 − 3
misrate-1e-4: m i s r a t e = 10 − 4 \mathrm{misrate} = 10^{-4} misrate = 1 0 − 4
misrate-1e-5: m i s r a t e = 10 − 5 \mathrm{misrate} = 10^{-5} misrate = 1 0 − 5
misrate-1e-6: m i s r a t e = 10 − 6 \mathrm{misrate} = 10^{-6} misrate = 1 0 − 6
These tests use identical samples with varying misrates to validate the monotonicity property: smaller misrates (higher confidence) produce wider bounds. The sequence demonstrates how bound width increases as misrate decreases, helping implementations verify correct margin calculation.
Unsorted tests — verify independent sorting of x \mathbf{x} x and y \mathbf{y} y (15 tests):
unsorted-x-natural-5-5: x = ( 5 , 3 , 1 , 4 , 2 ) \mathbf{x} = (5, 3, 1, 4, 2) x = ( 5 , 3 , 1 , 4 , 2 ) , y = ( 1 , 2 , 3 , 4 , 5 ) \mathbf{y} = (1, 2, 3, 4, 5) y = ( 1 , 2 , 3 , 4 , 5 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (X reversed, Y sorted)
unsorted-y-natural-5-5: x = ( 1 , 2 , 3 , 4 , 5 ) \mathbf{x} = (1, 2, 3, 4, 5) x = ( 1 , 2 , 3 , 4 , 5 ) , y = ( 5 , 3 , 1 , 4 , 2 ) \mathbf{y} = (5, 3, 1, 4, 2) y = ( 5 , 3 , 1 , 4 , 2 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (X sorted, Y reversed)
unsorted-both-natural-5-5: x = ( 5 , 3 , 1 , 4 , 2 ) \mathbf{x} = (5, 3, 1, 4, 2) x = ( 5 , 3 , 1 , 4 , 2 ) , y = ( 5 , 3 , 1 , 4 , 2 ) \mathbf{y} = (5, 3, 1, 4, 2) y = ( 5 , 3 , 1 , 4 , 2 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (both reversed)
unsorted-x-shuffle-5-5: x = ( 3 , 1 , 5 , 4 , 2 ) \mathbf{x} = (3, 1, 5, 4, 2) x = ( 3 , 1 , 5 , 4 , 2 ) , y = ( 1 , 2 , 3 , 4 , 5 ) \mathbf{y} = (1, 2, 3, 4, 5) y = ( 1 , 2 , 3 , 4 , 5 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (X shuffled)
unsorted-y-shuffle-5-5: x = ( 1 , 2 , 3 , 4 , 5 ) \mathbf{x} = (1, 2, 3, 4, 5) x = ( 1 , 2 , 3 , 4 , 5 ) , y = ( 4 , 2 , 5 , 1 , 3 ) \mathbf{y} = (4, 2, 5, 1, 3) y = ( 4 , 2 , 5 , 1 , 3 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (Y shuffled)
unsorted-both-shuffle-5-5: x = ( 3 , 1 , 5 , 4 , 2 ) \mathbf{x} = (3, 1, 5, 4, 2) x = ( 3 , 1 , 5 , 4 , 2 ) , y = ( 2 , 4 , 1 , 5 , 3 ) \mathbf{y} = (2, 4, 1, 5, 3) y = ( 2 , 4 , 1 , 5 , 3 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (both shuffled)
unsorted-demo-unsorted-x: x = ( 5 , 1 , 4 , 2 , 3 ) \mathbf{x} = (5, 1, 4, 2, 3) x = ( 5 , 1 , 4 , 2 , 3 ) , y = ( 3 , 4 , 5 , 6 , 7 ) \mathbf{y} = (3, 4, 5, 6, 7) y = ( 3 , 4 , 5 , 6 , 7 ) , m i s r a t e = 0.05 \mathrm{misrate} = 0.05 misrate = 0.05 (demo-1 X unsorted)
unsorted-demo-unsorted-y: x = ( 1 , 2 , 3 , 4 , 5 ) \mathbf{x} = (1, 2, 3, 4, 5) x = ( 1 , 2 , 3 , 4 , 5 ) , y = ( 7 , 3 , 6 , 4 , 5 ) \mathbf{y} = (7, 3, 6, 4, 5) y = ( 7 , 3 , 6 , 4 , 5 ) , m i s r a t e = 0.05 \mathrm{misrate} = 0.05 misrate = 0.05 (demo-1 Y unsorted)
unsorted-demo-both-unsorted: x = ( 4 , 1 , 5 , 2 , 3 ) \mathbf{x} = (4, 1, 5, 2, 3) x = ( 4 , 1 , 5 , 2 , 3 ) , y = ( 6 , 3 , 7 , 4 , 5 ) \mathbf{y} = (6, 3, 7, 4, 5) y = ( 6 , 3 , 7 , 4 , 5 ) , m i s r a t e = 0.05 \mathrm{misrate} = 0.05 misrate = 0.05 (demo-1 both unsorted)
unsorted-identity-unsorted: x = ( 4 , 1 , 5 , 2 , 3 ) \mathbf{x} = (4, 1, 5, 2, 3) x = ( 4 , 1 , 5 , 2 , 3 ) , y = ( 5 , 1 , 4 , 3 , 2 ) \mathbf{y} = (5, 1, 4, 3, 2) y = ( 5 , 1 , 4 , 3 , 2 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (identity property, both unsorted)
unsorted-negative-unsorted: x = ( − 1 , − 5 , − 3 , − 2 , − 4 ) \mathbf{x} = (-1, -5, -3, -2, -4) x = ( − 1 , − 5 , − 3 , − 2 , − 4 ) , y = ( − 2 , − 4 , − 3 , − 5 , − 1 ) \mathbf{y} = (-2, -4, -3, -5, -1) y = ( − 2 , − 4 , − 3 , − 5 , − 1 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (negative values unsorted)
unsorted-asymmetric-5-10: x = ( 2 , 5 , 1 , 3 , 4 ) \mathbf{x} = (2, 5, 1, 3, 4) x = ( 2 , 5 , 1 , 3 , 4 ) , y = ( 10 , 5 , 2 , 8 , 4 , 1 , 9 , 3 , 7 , 6 ) \mathbf{y} = (10, 5, 2, 8, 4, 1, 9, 3, 7, 6) y = ( 10 , 5 , 2 , 8 , 4 , 1 , 9 , 3 , 7 , 6 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (asymmetric sizes, both unsorted)
unsorted-duplicates: x = ( 3 , 3 , 3 , 3 , 3 ) \mathbf{x} = (3, 3, 3, 3, 3) x = ( 3 , 3 , 3 , 3 , 3 ) , y = ( 5 , 5 , 5 , 5 , 5 ) \mathbf{y} = (5, 5, 5, 5, 5) y = ( 5 , 5 , 5 , 5 , 5 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (all duplicates, any order)
unsorted-mixed-duplicates-x: x = ( 2 , 1 , 3 , 2 , 1 ) \mathbf{x} = (2, 1, 3, 2, 1) x = ( 2 , 1 , 3 , 2 , 1 ) , y = ( 1 , 1 , 2 , 2 , 3 ) \mathbf{y} = (1, 1, 2, 2, 3) y = ( 1 , 1 , 2 , 2 , 3 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (X has unsorted duplicates)
unsorted-mixed-duplicates-y: x = ( 1 , 1 , 2 , 2 , 3 ) \mathbf{x} = (1, 1, 2, 2, 3) x = ( 1 , 1 , 2 , 2 , 3 ) , y = ( 3 , 2 , 1 , 3 , 2 ) \mathbf{y} = (3, 2, 1, 3, 2) y = ( 3 , 2 , 1 , 3 , 2 ) , m i s r a t e = 10 − 2 \mathrm{misrate} = 10^{-2} misrate = 1 0 − 2 (Y has unsorted duplicates)
These unsorted tests are critical because ShiftBounds \operatorname{ShiftBounds} ShiftBounds computes bounds from pairwise differences, requiring both samples to be sorted independently. The variety ensures implementations dont incorrectly assume pre-sorted input or sort samples together. Each test must produce identical output to its sorted counterpart, validating that the implementation correctly handles the sorting step.
No performance test — ShiftBounds \operatorname{ShiftBounds} ShiftBounds uses the FastShift \text{FastShift} FastShift algorithm internally, which is already validated by the Shift \operatorname{Shift} Shift performance test. Since bounds computation involves only two quantile calculations from the pairwise differences (at positions determined by PairwiseMargin \operatorname{PairwiseMargin} PairwiseMargin ), the performance characteristics are equivalent to computing two Shift \operatorname{Shift} Shift estimates, which completes efficiently for large samples.