I'm trying to use Morlet wavelet to reduce noise in my signal. I found formula for Morlet wavelet
$$\Psi(x) = \frac{1}{\sqrt{\pi\cdot \textrm{bandwidth}}} \cdot \exp\left(i \cdot 2\pi \cdot \textrm{centerFreq} \cdot x\right)\cdot\exp\left(\frac{x^2}{\textrm{bandwidth}}\right)$$
(sb told me I shoud use formula for complex Morlet wavelet)
I also got CWT formula
$$C = \int f(t) \cdot \frac{1}{\sqrt{\textrm{scale}}} \cdot \Psi\left(\frac{t-\textrm{shift}}{\textrm{scale}}\right)dt$$
I convert both formulas to java code
public double morletRe(double x)
{
return (1/Math.sqrt(Math.PI*fb))*Math.cos(2*Math.PI*fc*x)* Math.exp(x*x/fb);
}
public double[] cwt(double[] data,double scale, double position)
{
double[] newData = new double[data.length];
for (int t = 0; t<data.length; t++ )
{
newData[t] = data[t]*(morletRe(t-position)/scale)[0])/Math.sqrt(scale);
}
return newData;
}
But in the results I get a strange chart which is completely not related to my data, is anyone can point me what I'm doing wrong? regards.
exp(x^2 / bandwidth)
grows very fast. Maybe it'sexp(-x^2/bw)
? Also, where are you calculating the integral? Does the function that callscwt
calculate a sum over the array that's returned? $\endgroup$ – Niki Estner Sep 3 '12 at 13:34