All problems
Wavelet Energy Share
Problem
Compute the share of signal energy carried by the first-level Haar detail coefficients. Split the series into consecutive pairs; each pair gives approximation (a + b)/sqrt(2) and detail (b - a)/sqrt(2).
Return the detail energy divided by the total energy of both coefficient types, or 0.0 when total energy is zero or the series has fewer than two points.
Hint
A high detail share means the series changes quickly at the finest scale.
Test cases
case 1
in: [[1,2,3,4]]
expected: 0.033333333333333326
case 2
in: [[1,1,1,1]]
expected: 0
case 3
in: [[1,0,1,0]]
expected: 0.5
case 4
in: [[2,2,2,3]]
expected: 0.023809523809523808
Starter codePython
def wavelet_energy_share(series):
# Your code here
pass4 test cases · run your code against them in the editor