> Where it came from before that, I know not.

I first saw the algorithm in the APL Quote-Quad magazine
in the 1970's.  I'll see if I can find it in my (incomplete)
collection of Quote-Quads.



----- Original Message -----
From: Mike Powell <[EMAIL PROTECTED]>
Date: Saturday, March 8, 2008 19:09
Subject: Re: [Jprogramming] Is there a tacit version EMA?
To: Programming forum <[email protected]>

> Xu,
> 
> Your EMA question is related to algorithms for linear 
> recurrence  
> relations. There is a much loved algorithm (probably because 
> it's  
> usually found to be lean and mean) that I first encountered at 
> IP  
> Sharp in a newsletter quiz. We used it all over the place,  
> particularly wherever a present value or discounted cash flow 
> was in  
> play. Where it came from before that, I know not. It goes like this.
> 
> If you have a linear recurrence relation of the form:
> 
> r[0] is m[0] times a[0]
> r[i] is a[i] + m[i] times r[i-
> 1]          (i >0)
> 
> then this can be calculated in vector languages in the following way:
> 
> a recur m;t
> t is timesscan m
> r is t times plusscan a div t
> 
> I'd be most interested to see a J algorithm for this, 
> particularly a  
> tacit one. I note that we have a reflexive piece (t) and that 
> there  
> may be an opportunity for an inverse (* and %).
> 
> As far as the EMA is concerned, I suggest Xu's original 
> requirement is  
> solved with:
> 
> (y[0] , k times 1 drop y) recur (length y) replicate 1 - k
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to