Re: computation of autocovariance
- To: mathgroup at smc.vnet.net
- Subject: [mg46236] Re: computation of autocovariance
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 12 Feb 2004 07:16:01 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <c04ehe$gbr$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
this is a lausy code and you should spend some
time reading "The Mathematica Book". Anyway
Try
m = Tr[x];
autocovS = Table[0, {60}];
For[j = 1, j < 61, j++,
autocovS[[j]] =
1/Length[x] - j +
Sum[(x[[i]] - m)*(x[[i + j]] - m), {i, 1, Length[x] - j - 1, 1}]]
Regards
Jens
paolo wrote:
>
> I am computing the autocovariance, with temporal lags from 1 to 60, of a time serie but my procedure does not works.
> Can you help me?
>
> x={timeserie}
>
> For[j=1,j<61,j++,
> autocovS[[j]]=1/Length[x]-j + Sum[(x[[i]]-Mean[x])*(x[[i+j]]-Mean[x]),{i,1,Length[x]-j-1,1}]]
>
> when i evaluate the procedure, Mathematica reply
>
> "Part specification autocovS?j? is longer than depth of object."
>
> thanks
>
> Paolo Tarpanelli