Outliers interview question

Preprocessing & Feature EngineeringOutliersDescriptive Statisticshard

A temperature sensor produced 20 readings: 17 between 48 and 52, plus 99, 100 and 101. The table shows their summary statistics. A rule that flags |z| > 3 using the mean and standard deviation flags nothing. What is the best explanation and fix?

StatisticValue
n20
Mean57.4
Standard deviation18.4
Median50
MAD (median absolute deviation)1.0
Three largest readings99, 100, 101
  1. AThe largest reading has z = (101 − 57.4) / 18.4 ≈ 2.4, inside three standard deviations, so all three readings are plausible for this sensor and the z-score rule works as designed.
  2. BZ-scores must be computed after min-max scaling the readings to [0, 1]; on the raw scale the large units hide the outliers, and rescaling would make the three readings stand out.
  3. CThe readings are not normally distributed, so the z-score should be computed on log-transformed values; on the log scale the variance stabilises and the three readings exceed |z| > 3.
  4. DThe three extremes inflate the mean and SD that define the cut-off (masking); a robust z-score, 0.6745 × (x − median) / MAD, gives about 33 for the reading 99 and flags all three.
Show the answer and explanation

Correct answer: D, The three extremes inflate the mean and SD that define the cut-off (masking); a robust z-score, 0.6745 × (x − median) / MAD, gives about 33 for the reading 99 and flags all three.

Explanation Outliers

Classic z-scores use the mean and standard deviation, and both are themselves pulled by outliers. With several extreme points, the SD inflates so much that the extremes no longer look extreme. This is called masking.

Here z(101) = (101 − 57.4) / 18.4 ≈ 2.4, below 3, so nothing is flagged even though three readings are double the normal level.

A robust z-score replaces the mean with the median and the SD with the MAD (median absolute deviation):

robust z = 0.6745 × (x − median) / MAD

The constant 0.6745 makes the MAD comparable to σ for normal data (σ ≈ 1.4826 × MAD). For the reading 99: 0.6745 × 49 / 1.0 ≈ 33, far beyond the usual cut-off of 3.5 (Iglewicz and Hoaglin). The median and the MAD have a 50% breakdown point, so up to half the data can be contaminated before they break down.

Why the distractors fail:

  • A largest z of about 2.4 is the symptom of masking, not evidence that the readings are plausible.
  • Min-max scaling, like any linear rescaling, leaves z-scores unchanged.
  • A log transform helps with skew, but on the log scale the mean and SD are inflated by the same three points; the largest z is still only about 2.35.

Interview tip: rank outlier rules by robustness (z-score < IQR fences < MAD, with breakdown points of 0%, 25% and 50%) and add that with small samples |z| has a hard ceiling of (n − 1)/√n, so a 3-SD rule can never fire for n ≤ 10.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Preprocessing & Feature Engineering questions

  1. A colleague reports a cross-validated AUC of 0.91 with this code on 200 customers and 10,000 features. As a sanity check you rerun it with randomly permuted…
  2. For an offline consumption report (not a forecasting feature), an analyst fills gaps in a building's daily energy readings. The readings were logged on…
  3. A card-fraud dataset was extracted on 30 June. A transaction's label is 1 if a chargeback had arrived by the extraction date, and chargebacks can arrive up to…
  4. A retailer's click model has 200M impressions, 2M of them clicks. To cut training cost, you keep every click and 1 in 10 non-clicks, and give each kept…
  5. A bank vectorizes 2 million support tickets with TF-IDF over a 500,000-term vocabulary; the sparse matrix has about 100 non-zeros per row (≈ 2.4 GB in CSR…