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

Home » Public Forums » archive » Re: possible bug in a_correlate()
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: possible bug in a_correlate() [message #35829] Fri, 01 August 2003 08:29
Chris[2] is currently offline  Chris[2]
Messages: 39
Registered: August 2003
Member
Hi Tim,

This is not a bug. In Jenkins & Watts (Spectral Analysis and its
Applications), p. 182, they discuss both definitions of the autocorrelation
function (one with the mean of all n, and the other with the mean over the
first and last N-m values).

As they state, "the use of the estimate [using N-m] is not recommended on
the grounds that, whereas it is a reasonable estimate of rho(k) when
considered in isolation from other values of the acf [autocorrelation
function], it is not a satisfactory estimate when a set of estimates r(1),
r(2),...r(m) is required for the first m autocorrelations rho(1),
rho(2),...rho(m)."

They go on to state, "The main disadvantage of [using N-m] is that two means
are used for the mean correction and that these change with lag...the
estimates are not positive definite...and may lead to curious behavior of
the estimates of the spectrum..."

I will go ahead and put a comment to this effect in the a_correlate.pro
code. Thanks for pointing this out.

-Chris
Research Systems, Inc.

"Tim Osborn" <t.osborn@uea.ac.uk> wrote in message
news:3641786c.0308010702.4ea9fc4b@posting.google.com...
> Dear all,
>
> another possible bug to check with you all [this one could be more
> major than the total() one reported earlier today]!
>
> IDL Version 5.4 (OSF alpha).
>
> IDL> x=findgen(50)+randomn(seed,50)
>
> IDL> print,correlate(x[0:48],x[1:49])
> % Compiled module: CORRELATE.
> 0.998140
>
> IDL> print,a_correlate(x,[1])
> % Compiled module: A_CORRELATE.
> 0.940559
>
> Shouldn't these two give the same answer? The first correlates
> elements 0-48 with 1-49, while the second computes the lag-1
> autocorrelation of the 50-element vector.
>
> A quick check through the IDL code for a_correlate() seems to indicate
> a possible source of the bug. The function Auto_Cov computes the mean
> over the full length of the vector, whereas I think it should compute
> the mean over each segment separately (0:nx-m-1) and (m:nx-1), where m
> is the lag.
>
> Have I got this right, and has anyone else noticed or corrected this?
>
> Cheers
>
> Tim
[Message index]
 
Read Message
Previous Topic: Re: minor glitch in total()
Next Topic: Re: Searching PDF help in IDL 5.6

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

Current Time: Thu Oct 09 04:59:25 PDT 2025

Total time taken to generate the page: 0.56300 seconds