On Mon, Sep 29, 2008 at 4:55 AM, Matthew Brand <[EMAIL PROTECTED]> wrote:
> scan =. 1 : '}.@(u~/\.&.|.)'
> f =. 1 : '(((%m)*[) + (1-%m)*])'
>
> EMAfun1 =. ((2 % [:>: #) $: ])  : (4 :'(((x * [) +  (-.x) * ])/\.)&.|. y')
> EMA  =: EMAfun1"0 _ f. NB. don't know why can't do "0 _ in line above!

If you turn on linear display and examine EMA you will see why (it's
your use of $:).

Also, note that dyadic EMA is not equivalent to the implied use
f scan, and not just because of the shape of the result:
   10 EMA 1 10 100
1 91 181
   10 f scan 1 10 100
9.1 90.91

If it was, you could have defined:
      ema=: ((2% 1+ #) $: ]) :(4 :'x f scan y')

Finally, on my hardware:
   ts '30 f scan i.1000000'
1.33262 3.14333e8
   ts '30 EMA i.1000000'
1.24261 3.14346e8

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to