Search code examples
wavelet-transformhaar-waveletdwtpywaveletspywt

How pywt calculates dwt Haar coefficients?


I got this example of a 1D Haar wavelet transform from a book.

"The Haar wavelet transform of [11, 9, 5, 7] is given by [8, 2, 1, −1]."

When I calculate the same data with python PyWavelets (pywt) library I get different coefficients.

Is pywt normalizing the coefficients? Is there a documentation on the normalization process?

Here is my code:

import pywt

x = [11,9,5,7]

cA, cD = pywt.dwt(x, 'haar')
y = pywt.idwt(cA, cD, 'haar')

print(cA)
print(cD)
print(y)

and the result is:

[14.14213562  8.48528137]
[ 1.41421356 -1.41421356]
[11.  9.  5.  7.]

Thanks for any help!


Solution

  • @DaBler had the answer. Calculating the values as indicated here I get the same result on resolution 2 as with pywt.