IQR
Description
IQR returns the (optionally corrected) interquartile range, a robust estimator of scale, using Excel’s “inclusive” QUARTILE.INC. The “corrected” IQR is scaled by dividing the raw IQR by the IQR of the standard normal distribution; thus for normally-distributed data it can be considered an estimate of the population standard deviation.
Syntax
IQR(data, [corrected=FALSE]) where
datais the input univariate data (any shape), filtering out non-numeric valuescorrectedis a boolean on whether to divide by the correction factor
The function returns a scalar value.
Example
Usage is straightforward: pass in the data as the first argument, and optionally choose to return the corrected value by passing TRUE as the second argument. Note that Excel interprets non-zero values as TRUE so it is common to see syntax like =IQR(data,1) in a cell formula.
Source Code
IQR = LAMBDA(
data, // any shape
[corrected], // apply correction (normalization)
LET(
correction, IF(ISOMITTED(corrected), FALSE, corrected),
Q_1, QUARTILE.INC(data, 1),
Q_3, QUARTILE.INC(data, 3),
// correction 1.34897950039216 is the IQR of the std normal distr
k, IF(correction, 1.34897950039216, 1),
(Q_3 - Q_1) / k
)
);