MathGroup Archive 2009

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

Search the Archive

Replace Table[Sum...]...] with Functional code

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98476] Replace Table[Sum...]...] with Functional code
  • From: Andreas <aagas at ix.netcom.com>
  • Date: Fri, 10 Apr 2009 04:57:20 -0400 (EDT)

I use the following two functions to analyze time series:

mm[data_, period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t - i]]]) / Sqrt[i], {i, 1, period}] / period, {t, period + 1, Length[data]}]

mr[data_, period_] := Table[Sum[Log[data[[t - i]] / data[[-i + t - 1]]] * (Sqrt[i] - Sqrt[i - 1]), {i, 1, period}],{t, period + 2, Length[data]}]

They have a similar structure, Table[Sum[...]...], which sums a bunch of stuff from the time series at each point in the series.

I'd like to convert them into functional programing constructs, but as the increments in the Table function come into play in the Sum, I haven't been able to figure out a way to do it.

I've tried Map with Partition and a bunch of other things, but I could use some pointers.

Any help much appreciated.


  • Prev by Date: Re: escaping quote for use with a selectionplaceholder
  • Next by Date: Re: combining contourplot and regionplot
  • Previous by thread: NetLink SEHException in getDefaultLaunchString
  • Next by thread: Re: Replace Table[Sum...]...] with Functional code