Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-047

Z-Score Outlier Detection

Problem

Detect outliers by z-score using the population standard deviation: return the indices i (ascending) where |(x_i - mean) / std| > threshold.

If the variance is 0 or the input is empty, return [].

Hint

Use the population standard deviation, then compare |z| against the threshold.

Test cases

case 1
in: [[10,12,11,13,12,100],2]
expected: [5]
case 2
in: [[1,2,3,4,5],1.5]
expected: []
case 3
in: [[0,0,0,10],1.5]
expected: [3]
case 4
in: [[7,7,7],1]
expected: []
Starter codePython
def zscore_outliers(values, threshold):
    # Your code here
    pass

4 test cases · run your code against them in the editor