Functions > Data Analysis > Outliers and NaN > Example: The Interquartile Range Method for Detecting Outliers
  
Example: The Interquartile Range Method for Detecting Outliers
Find outliers using the interquartile range method.
1. Define a data set that describes the heatflow.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
2. Define the interquartile range for the data set.
Click to copy this expression
Click to copy this expression
Click to copy this expression
3. Define the boundaries outside of which a point is labelled as an outlier.
Click to copy this expression
Click to copy this expression
4. In vector zero, assign a value of zero for each outlier detected. Use this vector to find the index of each outlier.
Click to copy this expression
Click to copy this expression
Click to copy this expression
5. In vector non_zero, keep only the outliers as nonzero values. Use this vector to find the value of each outlier.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
The boxplot function uses the interquartile range method to detect outliers and returns the same values as the ones calculated above. In the output vector below, the outliers are the last four elements:
Click to copy this expression
6. Plot the data and the outliers.
Click to copy this expression
The outliers are indicated with the blue boxes.