MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: correlation function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128698] Re: correlation function
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Sun, 18 Nov 2012 17:14:01 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <k8a8el$8bj$1@smc.vnet.net>
  • Reply-to: nma at 12000.org

On 11/18/2012 3:06 AM, jure lapajne wrote:
> Hello,
> I'm having hard time calculating correlation (autocorrelation) function of
> two lists (list). I'm trying two different ways of calculating it. One way
> is to use fourier transform and second way is to use Mathematica's function
>   ListCorrelate. I get different results but have no idea why. Here's my code:
>
> korelacija1 = ListCorrelate[data, data, {1, 1}];
> korelacija11 = Abs[InverseFourier[Abs[Fourier[data]]^2]];
>
> All elements of "data" are real. I have two Abs in second line because for some reason
>InverseFourier returns small imaginary parts - I know it shouldn't. It's probably only numerical error.
>
> Thanks for help.
>

-----------------------------
data  = Table[RandomReal[], {10}];
parms = FourierParameters -> {1, -1};
fft   = Fourier[data, parms];
res1  = Chop[fft*Conjugate[fft]];
res2  = Chop[Fourier[ListCorrelate[data, data, {1, 1}], parms]];
Chop[res1 - res2]
------------------------

Out[38]= {0,0,0,0,0,0,0,0,0,0}

--Nasser





  • Prev by Date: Re: Subscript on plus expression
  • Next by Date: Removing rows from a table
  • Previous by thread: Re: correlation function
  • Next by thread: Re: correlation function