I have difficulty to understand the results I get with implementing Parseval's Theorem in Python to DWT. I have the good results getting the Energy with Fourier transform and the time series in python:
# Parseval theorem energy
def ParsevalTheorem(data):
energy_sum = 0
for i in range(len(data)):
energy_sum += abs(data[i])**2
return energy_sum
# dwt_data[0] => approximation component at final level, dwt_data[1:] => detail components
def DWTParseval(dwt_data):
details_sum = 0
for i in range(len(dwt_data)-1):
details_sum += ParsevalTheorem(dwt_data[i+1])
approx_sum = ParsevalTheorem(dwt_data[0])
final_sum = approx_sum + details_sum
return final_sum
fourierTransform = np.fft.fft(short_signal)
print("fourier energy: ", ParsevalTheorem(np.abs(fourierTransform))/len(fourierTransform))
print("Org energy: ", ParsevalTheorem(short_signal))
print("DWT energy: ", DWTParseval(app1)) # app1 is haar discrete wavelet transform using pywt.wavedec(data, "haar", level = 3)
Results:
fourier energy: 1305035.7546624008
Org energy: 1305035.7546624022
DWT energy: 1309077.6827128115
I've gathered the information on using Parseval Theorem from equation: Equation Link1
I have also encountered another equation to get the Energy but if I divide the Approximation sum with it's length it's in whole different scope than the original signal energy: Equation Link2
I some what understand the Parseval theorem when dealing with fourier transform, but lost with these equations when dealing with DWT.
PS: I know there is more Pythonic way to do the code but I intend to apply it in a different language also.