[Bug?] getMeanFreq gives non-monotonous values for some wavelets
Hi,
I've noticed some unexpected behaviour of the function getMeanFreq, which returns non-monotonous values for some wavelets. I stumbled upon this issue when playing around with the example code of the readme; for some wavelets, the heatmap would not be plotted because it requires increasing y-values, which are given by getMeanFreq in the example code.
Disclaimer: I have very little knowledge of wavelets and how they function. Perhaps this behaviour is expected or even intended; it does strike me as quite odd, though.
I have not done a thorough test but tried only a few cases. My observations are as such:
- no issues for Morlet, no matter what parameters I gave it
- Battle-Lemarie 4 is problematic for β=1 and large signals but fine for short-ish ones (<10000)
- Haar is problematic even for comparable short signals (~1000)
MWE:
using ContinuousWavelets, Plots
x = 100000 # cBatt4 is fine for x<10000 but cHaar has issues even for ~1000
c1 = wavelet(Morlet(), β=1)
f1 = getMeanFreq(computeWavelets(x, c1)[1])
c2 = wavelet(cBatt4, β=1) # no problem for β=2, but β=1 causes issues for large x
f2 = getMeanFreq(computeWavelets(x, c2)[1])
c3 = wavelet(cHaar)
f3 = getMeanFreq(computeWavelets(x, c3)[1])
plot(f1, yscale=:log10, label="Morlet()", xlabel="i", ylabel="νᵢ", key=:bottomright)
plot!(f2, label="cBatt4")
plot!(f3, label="cHaar")
The resulting plot:
Should this behaviour be intended, please feel free to discard this report. Many thanks for providing this package!
Thanks for the detailed experimentation and writeup!
Those should be straight lines for β=1; the way the ContOrtho orthogonal wavelets are calculated is quite different from the inherently continuous ones like Morlet or Dog2. Looks like there's a bug in the way I generate those wavelets.
Finally got around to this, turns out I was using a pretty nonstandard 1-norm based mean frequency rather than the power (2-norm), as used in DSP. Using that, the finite cut-off really messes with the mean frequency, which becomes glaringly apparent for discontinuous wavelets like Haar (it's a step function, so the frequency decay is particularly abysmal).
Haar still looks a bit weird, but it is actually monotonic