All problems
Level Shift Detect
Problem
Detect a level shift by splitting the series in half and comparing means: return True when abs(mean_first_half - mean_second_half) > threshold.
Return False for a series with fewer than two points.
Hint
The comparison is strict, so a difference exactly at the threshold is not a shift.
Test cases
case 1
in: [[1,1,1,5,5,5],2]
expected: true
case 2
in: [[1,2,3,4],10]
expected: false
case 3
in: [[1,2],0.4]
expected: true
case 4
in: [[5,5,5,5],0]
expected: false
Starter codePython
def level_shift_detect(series, threshold):
# Your code here
pass4 test cases · run your code against them in the editor