Might be a good idea to have MA, SMA, WMA and EWMA (+ anymore !?) in a library file somewhere so that people can just say:
require 'movingAverages' NB. Or whatever the J team want to call it. I suspect that a lot of J users are re-inventing the wheel on this one. And in my case at least, probably doing a bad job of it! 2009/11/29 Fraser Jackson <[email protected]>: > In J we often have both arguments arrays > > When the shape of one is a prefix of the shape of the other, the following > gives a weighted mean and two functions with consistent monadic and dyadic > use > NObs =: # : (+/ @([+((0&*)@]))) > Mean =: (+/%#) : ((+/@([*]))%([NObs])) > > In the general case there is often a kernel function to generate the > weights. In that case > constructing a conjunction to specify the changing weights for each point is > worth the effort. It is then easy to explore the effect of different > weighting functions adn to change the points at which weights are evaluated. > > ----- Original Message ----- > From: "Brian Schott" <[email protected]> > To: "Programming forum" <[email protected]> > Sent: Sunday, November 29, 2009 11:41 AM > Subject: Re: [Jprogramming] Moving averages of data > > >> Here are some ideas for weighted average (wa) and weighted moving average >> (wma) >> >> wa >> * %&(+/) [ >> wma >> [ wa"1 #...@[ ]\ ] >> 1 2 wa 10 20 >> 16.6667 >> 1 1 wa 10 20 >> 15 >> 1 2 1 wa 10 20 30 >> 20 >> 1 2 1 wma 10 20 30 40 50 >> 20 30 40 >> >> A recent thread discussed EWMA's >> http://www.jsoftware.com/pipermail/programming/2009-November/016898.html >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
