Last active
March 29, 2019 14:04
-
-
Save Josh-Tilles/5273905 to your computer and use it in GitHub Desktop.
implementation of an exponentially weighted moving-average function (instigated by http://grahamstratton.org/straightornamental/entries/moreclojure)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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