medianConfidenceInterval
medianConfidenceInterval(
sorted,level?):ConfidenceInterval
Defined in: confidence-interval.ts:95
Distribution-free confidence interval for the median of an already-sorted sample, bounded by the pair of order statistics whose ranks bracket the median with at least the requested confidence (normal approximation to the binomial rank bounds).
Unlike meanConfidenceInterval, no distributional assumption is made:
both bounds are actual sample values, which is what makes this robust to the
heavy right tail benchmark timings always have. The bounds are not generally
symmetric about the estimate, so estimate ± halfWidth does not reproduce
them.
A sample can be too small for the level to be reachable at all — the widest
possible interval spans only 1 - 2^-(n-1) — in which case the whole sample
is returned as the interval. At n = 1 that is a single point.
O(1) — the input is already sorted.
Parameters
Section titled “Parameters”sorted
Section titled “sorted”readonly number[]
The sample, in ascending order. Not modified, not re-checked.
level?
Section titled “level?”number = 0.95
Confidence level in (0, 1). Default 0.95.
Returns
Section titled “Returns”The interval, estimating the sample median.
Throws
Section titled “Throws”When the sample is empty, or level is outside (0, 1).