All problems
EMD First IMF
Problem
Extract the first intrinsic mode function with lite empirical mode decomposition. Build upper and lower envelopes by linearly interpolating through local maxima and minima (endpoints count as extrema), subtract their average from the signal, and repeat the sifting for the given number of iterations.
Return the final IMF. Series with fewer than three points are returned unchanged.
Hint
Sifting removes the local mean so the IMF oscillates around zero.
Test cases
case 1
in: [[1,3,2,5,4],2]
expected: [0,0.625,-0.9375,0.75,0]
case 2
in: [[1,2,4,7,11],1]
expected: [0,-1.5,-2,-1.5,0]
case 3
in: [[3,1,4,1,5,9,2,6],1]
expected: [0,-1.25,1.5,-2.333333333333333,0.666666666666667,3.666666666666667,-2.75,0]
case 4
in: [[5,5,5],1]
expected: [0,0,0]
Starter codePython
def emd_first_imf(series, iterations):
# Your code here
pass4 test cases · run your code against them in the editor