MathGroup Archive 2006

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

Search the Archive

RE: Efficient compounding of growth figures

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67971] RE: Efficient compounding of growth figures
  • From: "Michael Stern" <stern at merrinmanagement.com>
  • Date: Wed, 19 Jul 2006 05:21:11 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I found the answer to my own question in a posting on this list from 2001.

 

FoldList[#1(1+#2)&,1, samplelist]

 

Thanks,

 

MS


  _____  

From: Michael Stern [mailto:stern at merrinmanagement.com] 
To: mathgroup at smc.vnet.net
Subject: [mg67971] Efficient compounding of growth figures

 

I have a list of periodic percentage changes in a time series. For example,

samplelist= {0.018, 0.017, 0.009, 0.022, 0.009, -0.005, 0.027, 0.02, 0.013};

I need to create a new list that shows the effect of compounding these
changes over time. In other words, element n of the answer list equals
(1+Part[samplelist,1]) * (1+Part[samplelist,2]) * ... *
(1+Part[samplelist,n])

The answer, in the case of the example above, is {1.018, 1.03531, 1.04462,
1.06761, 1.07721, 1.07183, 1.10077, 1.12278, 1.13738}.

I have created the following function, which gives the correct answer,
inserting the starting normalized value 1 at the start of the list. 

compoundlist[changes_]:=Table[Product[Prepend[1 + changes, 1]j
<http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=j> ,
{j, 1, i}], {i, 1, Length[Prepend[changes, 1]]}] 

This works perfectly but it is very inefficient. It repeats calculations
over and over again that need to be done only once. I would appreciate any
counsel on how to do this more efficiently.

Thanks in advance,

 

Michael Stern




  • Prev by Date: RE: LogLogErrorListPlot?
  • Next by Date: Re: Why Does Repeated Dot Product Take So Long?
  • Previous by thread: Re: WebServices InstallService bug in 5.2 on Max OS X 10.4.7
  • Next by thread: Re: Efficient compounding of growth figures