Dan,

        The discussion (below) makes me think you may be
needing a different approach from what I was discussing. You
may wish to look at the following links. I am getting a
little out of my expertise here, but I think you have to
distinguish among the following three. The first two are
definitely distinct, and I am not sure whether the last two
are always disctinct or just b is a special case of c.

a) weighted moving averages,

b) exponentially weighted moving averages,which the
wikipedia link is discussing and

c) autoregressive moving averages, ARMA, which is a special
case of integrated autoregressive moving averages, ARIMA.

http://en.wikipedia.org/wiki/Exponential_smoothing
http://www.duke.edu/~rnau/411avg.htm  (this link is found in the one above it)


On Tue, 8 Apr 2008, Dan Bron wrote:

I wrote:
>  I need to "undo" an average.

Oleg wrote:
> How would you know what to }: each time?

This is the essence of my question.

If this were just a straight, unweighted moving average, we could just pretend  
L  was  N  copies of the precomputed average, and drop off the first of those.  
For example, the moving average you posted last week depends on knowing  L  :

           4 (+/%#)\ ?.~ 10
        5 3.5 1.75 2.25 3.25 5 5.75

But it can be reforumulated so that it doesn't.  This version only needs 
previous average and the new value, and arrives at the same answer:

           prevAvg =: (+/%#)@:}:   NB.  Pre-computed average
           newVal  =: {:           NB.  Latest value

           4  (# %~ newVal + prevAvg * <:@:#)\ ?.~ 10
        5 3.5 1.75 2.25 3.25 5 5.75


This would be exactly what I need, if not for that weighting wrinkle.  That's 
throwing me.  How could we extend the reformulation above (depending on prevAvg 
and newVal) to handle the fact that the most recent value is weighted by a 
known factor?

-Dan


(B=) <----------my "sig"

Brian Schott
Atlanta, GA, USA
schott DOT bee are eye eh en AT gee em ae eye el DOT com
http://schott.selfip.net/~brian/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to