pub fn sign_flip_interval(differences: &[f64], level: f64) -> Option<(f64, f64)>Expand description
The exact sign-flip interval on the center of differences, at a coverage of at least
level: the paired difference of two methods’ errors on the same flights, where a bootstrap
undercovers on a few (ADR-257 §3).
The sign-flip test of a center μ takes the 2ⁿ ways of flipping the signs of dᵢ − μ as
equally likely, as they are when each difference is drawn from a distribution symmetric about
μ and independent. Inverted, it gives Hartigan’s interval (J. A. Hartigan, “Using subsample values as typical
values”, J. Am. Stat. Assoc. 64, 1969, pp. 1303–1317, Theorem 1): the means of the 2ⁿ − 1
non-empty subsets of the differences cut the line into 2ⁿ intervals, each holding the
center with probability 2⁻ⁿ. From the k-th smallest subset mean to the k-th largest
holds it with probability 1 − 2k/2ⁿ, for independent differences each symmetric about it, so
k is the largest whole number with
2k/2ⁿ ≤ 1 − level. Where k is 0, no pattern of signs is rare enough to reject anything:
the interval is the whole line, (−∞, ∞), as it is at 95% for 5 flights or fewer.
Returns None for no differences, more than 20 (a million subsets), a level not inside 0 to
1, or a difference that isn’t a number.