Example: The Interquartile Range Method for Detecting Outliers
Find outliers using the interquartile range method.
1. Define a data set that describes the heatflow.
2. Define the interquartile range for the data set.
3. Define the boundaries outside of which a point is labelled as an outlier.
4. In vector zero, assign a value of zero for each outlier detected. Use this vector to find the index of each outlier.
5. In vector non_zero, keep only the outliers as nonzero values. Use this vector to find the value of each outlier.
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: