Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# iqr

Interquartile range

y = iqr(X)
iqr(X,dim)

## Description

y = iqr(X) returns the interquartile range of the values in X. For vector input, y is the difference between the 75th and the 25th percentiles of the sample in X. For matrix input, y is a row vector containing the interquartile range of each column of X. For N-dimensional arrays, iqr operates along the first nonsingleton dimension of X.

iqr(X,dim) calculates the interquartile range along the dimension dim of X.

## 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
```

expand all

### Tips

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. 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.)