Skip to content

Alignment of Filters in dwt and wavedec #795

Description

@tycohen

I am trying to implement a matrix form of the DWT (for MCMC sampling reasons) and am comparing to pywt.dwt and wavedec (v 1.3.0) to confirm that I have constructed my matrix correctly. I am encountering a shift in the coefficients from dwt that I did not expect.

nsamp = 64
wavelet = "db4"
level = 1.
signal = np.zeros(nsamp)
signal[0] = 1.
cA_pywt, cD_pywt = pywt.dwt(signal, wavelet, mode="per")
# compute matrix W
# w_k = W @ signal
# cA_matrix = w_k[: nsamp // (2 ** (level + 1))]
# cD_matrix = w_k[nsamp // (2 ** (level + 1)) : nsamp // (2 ** level)]
# plot cA and cD

Image

I would have thought that for a delta function, the peak would be at cA_pywt[0], not cA_pywt[1]. Are the filters not aligned so that at k=0, wavelet.dec_lo[0] is aligned with signal[0]? Also, during decimation, is every even or every odd sample selected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions