iqr
Interquartile range: the spread between the 75th and 25th percentiles.
Category: Language Fundamentals > Data Types
Syntax
r = iqr(X)
Returns the interquartile range of a vector, or of each column of a matrix.
r = iqr(X, dim)
Computes along dimension dim.
Description
The interquartile range measures the width of the middle half of the data, so unlike the standard deviation it is not influenced by extreme values. It is the basis of the common rule that flags a point as an outlier when it lies more than 1.5 times iqr beyond the quartiles.
Input arguments
X- Numeric array.
dim- Dimension to operate along.
Output arguments
r- The difference
prctile(X, 75) - prctile(X, 25).
Example
Spread of a sample
iqr([1 2 3 4 5 6 7 8])
iqr([1 2 3 4 100])
std([1 2 3 4 100])
Output
ans = 4
ans = 26.2500
ans = 43.6177