Skip to content

Instantly share code, notes, and snippets.

@pingles
Created May 20, 2010 08:53
Show Gist options
  • Save pingles/407360 to your computer and use it in GitHub Desktop.
Save pingles/407360 to your computer and use it in GitHub Desktop.
(defn- exponential-smooth-recur
[current v factor]
(if (empty? v)
(rest current)
(letfn [(smooth
[y m]
(+ (* (- 1 factor) m) (* factor y)))]
(recur (conj current (smooth (first v) (last current))) (rest v) factor))))
(defn exponential-smooth
[v factor]
(exponential-smooth-recur [(first v)] v factor))
(println (exponential-smooth impressions 0.9))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment