On Jan 3, 2008 11:55 PM, Jack Andrews <[EMAIL PROTECTED]> wrote: > > You mean like J's /. adverb? > > looks interesting... i can kind of see how this could do moving > averages but can't see how you could apply it to a table like: > ----+----- > day | price > ----+------ > 0 | 1.00 > 1 | 1.20 > 2 | 1.15 > 3 | 1.25 > 4 | 2.90 > 5 | 2.70 > 6 | 2.75
I would use the dyad of verbs formed with \ for moving averages: avg=:+/ % # 3 avg\ 1 1.2 1.15 1.25 2.9 2.7 2.75 1.11667 1.2 1.76667 2.28333 2.78333 And, I had originally meant the dyad \. (which basically works somewhat like group by, except of course that you can use an arbitrary aggregation verb). Anyways... perhaps ^: would be interesting for you to consider. 3 avg\^:1: 1 1.2 1.15 1.25 2.9 2.7 2.75 1.11667 1.2 1.76667 2.28333 2.78333 3 avg\^:2: 1 1.2 1.15 1.25 2.9 2.7 2.75 1.36111 1.75 2.27778 3 avg\^:3: 1 1.2 1.15 1.25 2.9 2.7 2.75 1.7963 -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
