Re: time serie -> sum inside a loop
- To: mathgroup at smc.vnet.net
- Subject: [mg46138] Re: time serie -> sum inside a loop
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Sat, 7 Feb 2004 04:02:47 -0500 (EST)
- References: <bvvneh$j53$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
n=4; a = ToExpression[Table["a"<>ToString[k],{k,n}]] {a1, a2, a3, a4} mu=Tr[a]/Length[a] (1/4)*(a1 + a2 + a3 + a4) Y = Rest[FoldList[Plus, 0, a-mu]] {a1 + (1/4)*(-a1 - a2 - a3 - a4), a1 + a2 + (1/2)*(-a1 - a2 - a3 - a4), a1 + a2 + a3 + (3/4)*(-a1 - a2 - a3 - a4), 0} i=Random[Integer, {1, n}]; Y[[i]] == Sum[a[[k]]-mu, {k,i}] True Bob Hanlon In article <bvvneh$j53$1 at smc.vnet.net>, "paolo" <tarpanelli at libero.it> wrote: << Given a time serie a:= {a[[1]],a[[2]],a[[3]],...,a[[n]]} how can i solve this loop with mathematica? ------------- Y[[i]]:=Sum_(for k=1 to i) [a[[k]]-mu] ------------- where mu is the mean of time serie a.