Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discrete wavelet transform behaves like identity #81

Closed
ThomasChaffey opened this issue Jul 8, 2022 · 2 comments
Closed

Discrete wavelet transform behaves like identity #81

ThomasChaffey opened this issue Jul 8, 2022 · 2 comments

Comments

@ThomasChaffey
Copy link

Apologies if I am missing something very basic (I am only just learning about wavelets), but I believe there is a bug in dwt:

n = 2^6 - 1
u = cos.(2*pi*range(0, stop=1, length=n))
wav = wavelet(WT.haar) # also tested WT.db2
w = dwt(u, wav)
display(w == u)

This code returns true. Expected behaviour is that w is the discrete wavelet transform of u, something like I get running the same experiment in Mathematica.

Version info:

Wavelets 0.9.4
Julia 1.6.3

@JeffFessler
Copy link
Contributor

I can confirm seeing the same with Julia 1.7.3.
Changing the first line to n = 2^6 leads to output that makes more sense (I didn't check the values).
Typing ]?dwt might help you see the issue.
The default value of L (# of transform levels) is maxtransformlevels(x) which is 0 for your signal because its length has no factors of 2.
It is not a bug, but rather a limitation (or design choice) of the implementation here.
The same example in Matlab returns two vectors of length 32, meaning that it must be padding somehow, according to the dtwmode setting apparently.
You should decide what kind of padding you want. See related issue #80.

@ThomasChaffey
Copy link
Author

Wonderful, thank you! Setting n = 2^6 does indeed solve the problem, the output is as expected now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants