Created
August 8, 2014 13:29
-
-
Save thattommyhall/3707fdf6021b28e38545 to your computer and use it in GitHub Desktop.
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 percentiles [xs] | |
(let [sorted (sort xs) | |
how-many (count sorted) | |
percentile (fn [n] | |
(let [idx (Math/floor (* how-many (/ n 100)) )] | |
(nth sorted idx)))] | |
{:mean (mean xs) | |
:median (percentile 50) | |
:90 (percentile 90) | |
:95 (percentile 95) | |
:99 (percentile 99)})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment