-
Notifications
You must be signed in to change notification settings - Fork 111
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
Can't accurately compute C_d for an arbitrary wavelet. #1
Comments
@nabobalis @Cadair see section 3.i of Torrence and Compo for the maths. |
From what I can see either, the value in the paper is wrong or either Y_00 or W_D are returning the wrong values. For the morlet, is the frequency_rep function calculating the fourier transform of the Morlet wavelet as is given http://en.wikipedia.org/wiki/Morlet_wavelet ? |
It is implemented as in Table 1 of TC98 (paper here if you need it. ) I'm not sure how this maps to the wikipedia version. |
Yeah, it is the same as far as I can tell as the paper version. I can't find an issue with the code. |
Are we talking about the same thing? I'm comparing this code, i.e. def frequency_rep(self, w, s=1.0):
"""Frequency representation of morlet.
s - scale
w - angular frequency
"""
x = w * s
# heaviside mock
Hw = 0.5 * (np.sign(x) + 1)
return np.pi ** -.25 * Hw * np.exp((-(x - self.w0) ** 2) / 2) with the fourier transform on wikipedia: What I can't see is how the heaviside function is represented on wikipedia. |
Yeah, I do mean that. The last part of the equation vanishes for sigma Regardless, the code follows the paper. So I'm not sure what the problem is On 31 August 2014 13:51, aaren [email protected] wrote:
|
I was using the form for the wavelet given in table 1 of TC98 and not the normalised form given in equation 6 (to give unit energy). This goes some way to fixing github issue #1.
I made a mistake in the code. I'm still not getting the exact same value as TC98, but at least it's a lot closer (getting 0.724 now). |
The actual computation of Cdelta is a double summation of the fourier wavelet over scale and frequency. This is sensitive to the values of N, dj and s0 (dt cancels out). It looks like N just needs to be big enough (>1000), whereas dj and s0 can be a bit smaller than default. s0 is the smallest scale. The default choice for s0 is to find where this corresponds to the equivalent fourier period being equal to |
also set as property and remove ability to select value by call (can do it by indexing now) This affects the computation of Cdelta, which is now about 0.768 for the Morlet, without having to set the values of s0 and dj lower. Setting them lower doesn't change this much. See #1.
also set as property and remove ability to select value by call (can do it by indexing now) n.b. the frequencies returned by numpy are adimensional, on the interval [-1/2, 1/2], so we multiply by 2 * pi. This affects the computation of Cdelta, which now comes out as correct when s0 = 1 (for the Morlet). See #1.
08baf66 nearly fixes the issue, giving The wavelet variance is dependent on the value of
The scales are defined as sj = s0 * 2 ^ (j * dj), j=0, 1, ..., J (TC98 eq 9-10). We are told to choose s0 such that the equivalent fourier period is about 2 * dt. |
also set as property and remove ability to select value by call (can do it by indexing now) n.b. the frequencies returned by numpy are adimensional, on the interval [-1/2, 1/2], so we multiply by 2 * pi. This affects the computation of Cdelta, which now comes out as correct when s0 = 1 (for the Morlet). See #1.
also set as property and remove ability to select value by call (can do it by indexing now) n.b. the frequencies returned by numpy are adimensional, on the interval [-1/2, 1/2], so we multiply by 2 * pi. This affects the computation of Cdelta, which now comes out as correct when s0 = 1 (for the Morlet). See #1.
also set as property and remove ability to select value by call (can do it by indexing now) n.b. the frequencies returned by numpy are adimensional, on the interval [-1/2, 1/2], so we multiply by 2 * pi. This affects the computation of Cdelta, which now comes out as correct when s0 = 1 (for the Morlet). See aaren#1.
I started coding up my own implementation of an inverse continuous wavelet transform. While searching for my own solution to this same problem, I found your repo. I think the number quoted in the T&C paper is "wrong".
As you say, in the real, live, finite sample size case Cdelta is dependent on N, dj, and s0. If you use T&C eq. (5) to set up your w_k's, dt will affect the numerical integration step size (in the sum), even though it explicitly cancels. To reproduce the T&C result you need to use the exact settings they used. If you look in their fortran code, you'll see they set:
These are not the same values stated in T&C section 3.f. They also comment:
It appears that in practice T&C are over computing for numerical stability. Anyways, using their values, I can reproduce The main point is that T&C's quoted numbers are not general. I think it's best to compute Cdelta and any other empirically determined constants for a particular wavelet basis as needed and ignore the T&C values in their table 2. |
Thanks for the nice code! Here I wish to share what I figured out about The TC98
The For complex wavelet functions whose Fourier transform is specified to be 0 for The resulting Hope this helps! |
Added missing scale_from_period functionality for Paul + DOG wavelets
Example code:
The explicitly computed version is giving me a value of
(0.13708 + 0j)
, rather than the 0.776 that we expect for a Morlet with w0 = 6 (which is the default).The text was updated successfully, but these errors were encountered: