Open OverLordGoldDragon opened 4 years ago
Thanks, I am fine with exposing this parameter.
I will take a look at the info you found soon and review it a little closer.
@grlee77 Some interesting findings here (see bottom); to my surprise, pywt
seems to outperform scipy
on low scales. Also found a caveat2 (bottom) on integrated wavelet.
I'm curious on rationale behind integrated wavelet, which isn't documented on the site you found; perhaps it can be improved further.
Addresses this Issue. Detailed explanation here; a summary:
precision
distorts CWT, and heavily at high scales.64
are increasingly distorted.precision=10
is low, andprecision=12
does not add much computation cost, while considerably remedying 1-3.At the least, the user should get to decide
precision
instead of carving it in stone. And a doc/comment should be made about these caveats.Improvement comparison
Code
```python import numpy as np import matplotlib.pyplot as plt from pywt._extensions._pywt import DiscreteContinuousWavelet from pywt._functions import integrate_wavelet #%%########################################################################## def l2(x): return np.sqrt(np.sum(np.abs(x ** 2))) scales = np.power(2 ** (1 / 32), np.arange(1, 320 + 1)) wavelet = DiscreteContinuousWavelet('morl') #%%########################################################################## l2res = [] for precision in (10, 12, 14): l2res.append([]) for scale in scales: int_psi, x = integrate_wavelet(wavelet, precision=precision) step = x[1] - x[0] linrange = max(x) - min(x) j = np.arange(scale * linrange + 1) / (scale * step) j = j.astype(int) # floor if j[-1] >= int_psi.size: j = np.extract(j < int_psi.size, j) int_psi_scale = int_psi[j][::-1].real l2res[-1].append(l2(np.diff(int_psi_scale) * np.sqrt(scale))) #%%########################################################################## plt.plot(np.log2(scales), l2res[0]) plt.plot(np.log2(scales), l2res[1]) plt.plot(np.log2(scales), l2res[2]) plt.show() ```