Yeah. This is a linear filter and if you are evaluating arrays of them it might be faster in J to use array operations rather than multiplying it out term by term.
Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Devon > McCormick > Sent: Friday, September 26, 2008 5:44 PM > To: Programming forum > Subject: Re: [Jprogramming] scan operator > > Thanks, Henry. > > For > > f =. 1 : '(((%m)*[) + (1-%m)*])' > > we get > > 3 ewma 5#1 4 > 1 1 1 1 3 3.66667 3.88889 3.96296 3.98765 > > which is more like it. > > > On Fri, Sep 26, 2008 at 5:09 PM, Henry Rich > <[EMAIL PROTECTED]> wrote: > > > > > f =. 1 : '(([%m) + (1-%m)*])' > > > > isn't right. > > > > f =. 1 : '(((%m)*[) + (1-%m)*])' > > > > Henry Rich > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] On Behalf Of Devon > > > McCormick > > > Sent: Friday, September 26, 2008 5:04 PM > > > To: Programming forum > > > Subject: Re: [Jprogramming] scan operator > > > > > > Hi Matthew - > > > > > > are you sure this is correct? When I apply "ewma" to "5#1 > > > 4", I get this: > > > 3 ewma 5#1 4 > > > 1 1 1 1 3 3 3 3 3 > > > > > > I was under the impression that the terminal value should get > > > closer to 4, > > > not stick at 3. > > > > > > Regards, > > > > > > Devon > > > > > > On Fri, Sep 26, 2008 at 4:18 PM, Matthew Brand > > > <[EMAIL PROTECTED]>wrote: > > > > > > > This is a definition of EWMA using the scan adverb: > > > > > > > > NB. Scan for a parameterless function. > > > > scan =. 1 : '}.@(u~/\.&.|.)' > > > > > > > > NB. The EWMA weighting function must be defined as an adverb > > > > NB. to input the parameter: > > > > f =. 1 : '(([%m) + (1-%m)*])' > > > > > > > > ewma =. f scan > > > > 10 ewma i.10 > > > > > > > > or, > > > > 10 f scan i.10 > > > > > > > > > > > > > > > > > > > > On Fri, Sep 26, 2008 at 8:31 PM, Matthew Brand > > > <[EMAIL PROTECTED] > > > > >wrote: > > > > > > > > > Thanks, I see what you mean!!! > > > > > > > > > > ts=: 6!:2, 7!:[EMAIL PROTECTED] > > > > > > > > > > ts '# - (1 : ''}.@(u~/\.&.|.)'') i.1000' > > > > > 0.000193176 17664 > > > > > > > > > > ts '# - (1 : ''}.@(u~/\&.|.)'') i.1000' > > > > > 0.130687 30208 > > > > > > > > > > Also, \ does not give the right answer but \. does... I > > > might have done a > > > > > typing error. > > > > > > > > > > > > > > > On Fri, Sep 26, 2008 at 7:39 PM, Henry Rich > <[EMAIL PROTECTED]> > > > > wrote: > > > > > > > > > >> \. is faster than \ so use > > > > >> > > > > >> scan =. 1 : '}.@(u~/\.&.|.)' > > > > >> > > > > >> Henry Rich > > > > >> > > > > >> > -----Original Message----- > > > > >> > From: [EMAIL PROTECTED] > > > > >> > [mailto:[EMAIL PROTECTED] On Behalf > > > Of Matthew Brand > > > > >> > Sent: Friday, September 26, 2008 2:33 PM > > > > >> > To: Programming forum > > > > >> > Subject: Re: [Jprogramming] scan operator > > > > >> > > > > > >> > Thanks for the pointers, here it is: > > > > >> > scan =. 1 : '}.@: (((u~/)&.|.)\)' > > > > >> > - scan >: i.5 > > > > >> > _1 _4 _8 _13 > > > > >> > (1-2),((1-2)-3),(((1-2)-3)-4),((((1-2)-3)-4)-5) > > > > >> > _1 _4 _8 _13 > > > > >> > > > > > >> > Does this seem like something there ought to be a primitive > > > > >> > for, I think > > > > >> > that q might have one? Anyway, it looks like it > works so far. > > > > >> > I want to use > > > > >> > it to do exponentially weighted moving average EWMA, which > > > > >> > was a topic on > > > > >> > the forum earlier in the year. > > > > >> > > > > > >> > Cheers, > > > > >> > Matthew. > > > > >> > > > > > >> > On Fri, Sep 26, 2008 at 5:07 PM, Devon McCormick > > > > >> > <[EMAIL PROTECTED]> wrote: > > > > >> > > > > > >> > > Hi Matthew - maybe this is what you want: > > > > >> > > > > > > >> > > (1-2)-3 > > > > >> > > _4 > > > > >> > > -~/|.1 2 3 > > > > >> > > _4 > > > > >> > > ((1-2)-3)-4 > > > > >> > > _8 > > > > >> > > -~/|.1 2 3 4 > > > > >> > > _8 > > > > >> > > > > > > >> > > so, you could do "f~/|." > > > > >> > > > > > > >> > > On Fri, Sep 26, 2008 at 11:44 AM, Matthew Brand > > > > >> > <[EMAIL PROTECTED] > > > > >> > > >wrote: > > > > >> > > > > > > >> > > > Hi All, > > > > >> > > > > > > > >> > > > If I have a dyadic function f, how can I do > the following: > > > > >> > > > > > > > >> > > > (((y0 f y1) f y2) f y3... ) f yn > > > > >> > > > > > > > >> > > > I want to feed the result of x f y into the next > > > > >> > evaluation as the left > > > > >> > > > parameter. > > > > >> > > > > > > > >> > > > > > > > >> > > > Thanks, > > > > >> > > > Matthew. > > > > >> > > > > > > > >> > > > > > ---------------------------------------------------------------------- > > > > >> > > > For information about J forums see > > > > >> > http://www.jsoftware.com/forums.htm > > > > >> > > > > > > > >> > > > > > > >> > > > > > > >> > > > > > > >> > > -- > > > > >> > > Devon McCormick, CFA > > > > >> > > ^me^ at acm. > > > > >> > > org is my > > > > >> > > preferred e-mail > > > > >> > > > > > > >> > > > > > ---------------------------------------------------------------------- > > > > >> > > 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 > > > > >> > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > > > For information about J forums see > > > http://www.jsoftware.com/forums.htm > > > > > > > > > > > > > > > > -- > > > Devon McCormick, CFA > > > ^me^ at acm. > > > org is my > > > preferred e-mail > > > > ---------------------------------------------------------------------- > > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > > > > > ---------------------------------------------------------------------- > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > > > -- > Devon McCormick, CFA > ^me^ at acm. > org is my > preferred e-mail > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
