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
