[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] Cross correlation using FFT
From: |
Saurav Pathak |
Subject: |
[Help-gsl] Cross correlation using FFT |
Date: |
Wed, 19 Sep 2007 18:39:24 -0400 |
User-agent: |
Mutt/1.4.2i |
Hi All,
I am trying to calculate the cross correlation of two time series
using FFT. The effective part of the code is:
z = gsl_fft_real_radix2_transform(&x[0], 1, x.size());
z = gsl_fft_real_radix2_transform(&y[0], 1, y.size());
vector<double> c(n);
c[0] = x[0]*y[0];
c[n/2] = x[n/2]*y[n/2];
for (int i=1; i<n/2; ++i) {
c[i] = x[i]*y[i] + x[n-i]*y[n-i];
c[n-i] = x[n-i]*y[i] - x[i]*y[n-i];
}
z = gsl_fft_halfcomplex_radix2_inverse(&c[0], 1, c.size());
All is well, and I seem to be getting there except that the
correlations are not normalized properly. For example, c[0] =
111.899 when x and y are identical series of random numbers
with a stadard normal distribution. It should be 1.0.
I have checked the result against ccf in R.
What am I missing here? Thank you for your tips and comments
in advance.
--
saurav
- [Help-gsl] Cross correlation using FFT,
Saurav Pathak <=