Skip to content

Instantly share code, notes, and snippets.

@ichramm
Created May 13, 2020 03:54
Show Gist options
  • Save ichramm/2758ab964c9fa65b2dddf2f9dbff5ca9 to your computer and use it in GitHub Desktop.
Save ichramm/2758ab964c9fa65b2dddf2f9dbff5ca9 to your computer and use it in GitHub Desktop.
normal distribution of deltas
; data is a list of numbers
(let [deltas (loop [res '() rem data]
(if (empty? rem)
res
(recur (concat res
(map #(Math/abs (- % (first rem))) (rest rem)))
(rest rem))))
total (count deltas)
mean (/ (reduce + 0 deltas) (count deltas))
std-dev (-> (reduce #(+ % (Math/pow (- %2 mean) 2))
0
deltas)
(/ (dec total))
Math/sqrt)]
(println "total:" total)
(println "mean:" mean)
(println "std-dev:" std-dev))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment