TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

126. Outlier Detection (IQR)

Easy

Return the indices of outliers using the Tukey IQR rule.

Signature: def iqr_outliers(x: list, k: float = 1.5) -> list

Let Q1 and Q3 be the 25th and 75th percentiles, IQR = Q3 - Q1. An index i is an outlier if:

x[i] < Q1 - k * IQR or x[i] > Q3 + k * IQR

Return indices in ascending order.

Math

outlier(xi​)⟺xi​<Q1​−k⋅IQR∨xi​>Q3​+k⋅IQR

Asked at

NumPy

import numpy as np

 

def iqr_outliers(...):

    pass

🔒

Premium problem

Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.

Upgrade to PremiumBack to problems

Already premium?