All problems
Outlier Count by 3-Sigma
Problem
Return the number of values farther than 3 population standard deviations from the mean. Return 0 when data is empty or the standard deviation is zero. With a population standard deviation, a sample smaller than about 11 points cannot produce an outlier.
Hint
Compare abs(x - mean) against 3 * sd.
Test cases
case 1
in: [[1,2,3,4,5]]
expected: 0
case 2
in: [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100]]
expected: 1
case 3
in: [[7,7,7,7,7,7,7,7,7,7]]
expected: 0
case 4
in: [[-100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
expected: 1
case 5
in: [[10,12,14,16,18]]
expected: 0
Starter codePython
def outliers_3sigma(data):
# Your code here
pass5 test cases · run your code against them in the editor