Summarize distributions and investigate outliers
Describe center and spread, flag unusual observations, and review them in their original context.
On this page
Compare the mean, median, and quartiles
The median and interquartile range are less sensitive to extreme values than the mean and full range. Check the number of observations and use a histogram or box plot to see shape and skew. State how missing values were handled.
Flag values beyond an IQR fence
The IQR is the difference between the third and first quartiles. A common exploratory fence is 1.5 IQRs past either quartile. A flagged value could be a data error, a legitimate rare event, or evidence of a different group. Inspect it before deciding what to do.
import numpy as np
orders = np.array([10, 11, 12, 13, 14, 45])
q1, q3 = np.quantile(orders, [0.25, 0.75])
iqr = q3 - q1
flag = (orders < q1 - 1.5 * iqr) | (orders > q3 + 1.5 * iqr)
print(float(np.median(orders)), float(iqr))
print(orders[flag].tolist())
Download image
Example output
12.5 2.5 [45]