BasicsOutliersIQRGoogleMetaJane Street
Problem
Implement detect_iqr_outliers(x) returning a list of Python booleans (list[bool]) where True marks values strictly below Q1 - 1.5 * IQR or strictly above Q3 + 1.5 * IQR.
Why It Matters: Tukey's 1.5 × IQR fence is the standard non-parametric outlier detector because extreme anomalies don't corrupt Q1/Q3 the way they corrupt mean and standard deviation.
Function Signature
import numpy as np
def detect_iqr_outliers(x) -> list[bool]:
Sample Input & Output
Example 1: Single Extreme High Outlier
Input:
x = [10, 12, 13, 14, 15, 16, 100]
Expected Output:
[False, False, False, False, False, False, True]
Explanation: Q1 = 12.5, Q3 = 15.5, IQR = 3.0, upper fence = 15.5 + 4.5 = 20.0, flagging only 100.
Example 2: Clean Data With No Outliers
Input:
x = [1, 2, 3, 4, 5]
Expected Output:
[False, False, False, False, False]
Explanation: All points lie well inside [Q1 - 1.5*IQR, Q3 + 1.5*IQR], so every entry is False.
Constraints & Edge Cases
- Return a boolean list/array of the same length (
Truefor outliers). - Use strict inequalities (
v < loorv > hi). - Return a list of Python
bool(notnp.bool_).
Constraints & Evaluation Criteria
- Return a boolean list/array of the same length (`True` for outliers).
Hints
Python 3⌘/Ctrl+Enter to Run · ⌘/Ctrl+Shift+Enter to Submit
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
[10, 12, 13, 14, 15, 100]
Expected Output / Criteria
[False, False, False, False, False, True]