MathGroup Archive 2004

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

Search the Archive

Re: computation of autocovariance


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


  • Prev by Date: Re: Help with Nitegrate
  • Next by Date: Re: Algebraic Manipulation
  • Previous by thread: Re: computation of autocovariance
  • Next by thread: How to printout more digits?