comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: IDL autocorrelation function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: IDL autocorrelation function [message #49120] Wed, 21 June 2006 12:37
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
yveltje wrote:
> hi!
>
> I need to calculate the autocorrelation function "g" of some signal
> "S", the latter being vector with N elements. I did:
>
> lag = indgen( N )
> g = a_correlate( S, lag )
>
> This works fine for relatively small N, but above ~ 4,000,000 it says
> something like:
> subscript of S : low>0, high<N-1 etc.....
>
> I cannot see in a_correlate.pro why it does this.

I suspect you have integer overflow. The "standard" integer in IDL (and
you create an array of that type with the INDGEN function) is a short 16
bit integer, which can hold values from -2^15 to +2^15-1, which is
-32768 to +32767. Do

IDL> plot, indgen(n)

for n below and above 32767 and you'll see what I mean. The higher
values get wrapped over to negative values, and the A_CORRELATE function
issues an error when it tries to use those negative values as array
subscripts.

It should work if you use 32 bit long integers (LINDGEN instead of
INDGEN), or even 64 bit (L64INDGEN) if you go beyond 32 bits.

> I have also tried using the FFT which a lot faster and looks good but
> somehow the normalisation is not the same.

Are you using forward and reverse FFTs correctly? Also, in the
A_CORRELATE help it sais "the mean is subtracted before correlating".
Maybe it has to do with that.

> This all might be simple but
> I am useless with discrete fourier transform. :)
>

I can recommend the excellent book by E. Oran Brigham, "The Fast Fourier
Transform". Or Numerical Recipes, you can find it online (free).

Good luck,
Benjamin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Eclipse plugin for PV-WAVE?
Next Topic: IDL use to analyse MRI data

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:34:48 PDT 2025

Total time taken to generate the page: 0.00669 seconds