Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
implementation of an exponentially weighted moving-average function (instigated by http://grahamstratton.org/straightornamental/entries/moreclojure)
(defn ema [f values]
(reductions (fn [running v]
(let [one-minus-F (- 1 f)] ;naming intermediate results can help with the readability of non-associative operators.
(+ (* f v)
(* one-minus-F running))))
values))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment