push-value ( stats x -- stats )


Vocabulary
math.statistics.running

Inputs
statsan object
xan object


Outputs
statsan object


Definition


Methods

M:: object push-value ( stats x -- stats )
stats dup n>> zero?
[ x >>min x >>max ]
[ [ x min ] change-min [ x max ] change-max ] if
[ 1 + dup ] change-n swap :> n [ x + ] change-sum
x over mom1>> - :> delta delta n /f
:> delta_n delta_n sq :> delta_n2 delta delta_n * n 1 - *
:> term1 [
term1 delta_n2 * n sq 3 n * - 3 + * 6 delta_n2 *
stats mom2>> * + 4 delta_n * stats mom3>> * - +
] change-mom4
[ term1 delta_n * n 2 - * 3 delta_n * stats mom2>> * - + ]
change-mom3 [ term1 + ] change-mom2
[ delta_n + ] change-mom1 ;