Created
May 13, 2020 03:54
-
-
Save ichramm/2758ab964c9fa65b2dddf2f9dbff5ca9 to your computer and use it in GitHub Desktop.
normal distribution of deltas
This file contains hidden or 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
; 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