Function interquantileRange

Computes the interquantile range of data at the given quantile value in O(N) time complexity. For example, using a quantile value of either 0.25 or 0.75 will give the interquartile range. (This is the default since it is apparently the most common interquantile range in common usage.) Using a quantile value of 0.2 or 0.8 will give the interquntile range.

double interquantileRange(R) (
  R data,
  double quantile = 0.25
)
if (doubleInput!R);

If the quantile point falls between two indices, linear interpolation is used.

This function is somewhat more efficient than simply finding the upper and lower quantile and subtracting them.

Tip

A quantile of 0 or 1 is handled as a special case and will compute the plain old range of the data in a single pass.