Understanding Parseval's Theorem with Discrete Wavelet Transform

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.

The equation for the discrete wavelet transform (DWT) might be incomplete, with respect to the indices. I for instance think that in the second term of the RHS, the scaling factor should be $$N_j$$, not $$N_J$$ (and this depends a bit on how discrete wavelets are implemented). Basically, an orthogonal wavelet transform projects data onto basis elements gathered in groups called subbands. Each wavelet subband comes from $$N_j$$ vectors, with an additional $$N_J$$ vectors for the approximation. And normally, the total number of vectors should be (about, honestly, this depends on signal extension) the number of samples $$N$$, in other words: $$N=N_J +\sum_{j=1}^JN_j$$.