Paste: sma

Author: mrjbq7
Mode: factor
Date: Tue, 23 Sep 2008 06:00:19
Plain Text |
: sma ( seq n -- newseq )
    #! Simple moving average
    0 swap rot V{ } -roll
    [ [ length ] keep 2over <= rot drop ] 
    [ [ <slice> sum ] 3keep
      [ [ 1+ ] dip 1+ ] dip
      roll [ roll ] dip swap [ push ] keep -roll
    ] [ drop drop drop ] while ;

Annotation: improved

Author: mrjbq7
Mode: factor
Date: Tue, 23 Sep 2008 06:04:47
Plain Text |
: sma ( seq n -- newseq )
    #! Simple moving average
    clump [ mean ] map ;

New Annotation

Summary:
Author:
Mode:
Body: