Statistics Toolbox | ![]() ![]() |
Interquartile range (IQR) of a sample
Syntax
Description
computes the difference between the 75th and the 25th percentiles of the sample in X. The IQR is a robust estimate of the spread of the data, since changes in the upper and lower 25% of the data do not affect it. y = iqr(X)
If there are outliers in the data, then the IQR is more representative than the standard deviation as an estimate of the spread of the body of the data. The IQR is less efficient than the standard deviation as an estimate of the spread when the data is all from the normal distribution.
Multiply the IQR by 0.7413 to estimate (the second parameter of the normal distribution.)
Examples
This Monte Carlo simulation shows the relative efficiency of the IQR to the sample standard deviation for normal data.
x = normrnd(0,1,100,100); s = std(x); s_IQR = 0.7413 * iqr(x); efficiency = (norm(s - 1)./norm(s_IQR - 1)).^2 efficiency = 0.3297
![]() | inconsistent | iwishrnd | ![]() |