How to compute wavelet decomposition?

698 Views Asked by At

To get the output of the highpass and lowpass filter of the signal(function) we can use the following mathematical definition: this

So, i tried to compute it without the library using the following code with python 2.7:

import pywt # getting the low and highpass filter
w = pywt.Wavelet('db1')
lof = w.dec_lo
hif = w.dec_hi

x = [1,2,3,4]

y_high0 = x[0]*hif[0]
y_high1 = x[1]*hif[1]+x[2]*hif[0]
cD = (y_high0, y_high0) # (-0.7071067, -0.7071067)

y_low0 = x[0]*x[0]
y_low1 = x[1]*lof[1]+x[2]*lof[0]
cA = (y_low0, y_low0) # (0.7071067, 3.535533)

Then i got (-0.7071067, -0.7071067) for cD and (0.7071067, 3.535533) for cA. But when i use this code from the library, i got different answer:

import pywt
cA, cD = pywt.dwt([1, 2, 3, 4], 'db1')

The result is different with my own code. that is [ 2.12132034 4.94974747] for cA and [-0.70710678 -0.70710678] for cD.

So, the thing that i want to ask is, how actually wavelet decomposition is computed?

I am really new in this wavelet topic, i already read some introduction of this topic but i still got confused with its computation. I really appreciate your answer, thanks in advance :)

0

There are 0 best solutions below