all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
9
Task/Standard-deviation/Clojure/standard-deviation.clj
Normal file
9
Task/Standard-deviation/Clojure/standard-deviation.clj
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(defn std-dev [samples]
|
||||
(let [n (count samples)
|
||||
mean (/ (reduce + samples) n)
|
||||
intermediate (map #(Math/pow (- %1 mean) 2) samples)]
|
||||
(Math/sqrt
|
||||
(/ (reduce + intermediate) n))))
|
||||
|
||||
|
||||
(println (std-dev [2 4 4 4 5 5 7 9])) ;;2.0
|
||||
Loading…
Add table
Add a link
Reference in a new issue