Skip to content

Instantly share code, notes, and snippets.

@thattommyhall
Created August 8, 2014 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thattommyhall/3707fdf6021b28e38545 to your computer and use it in GitHub Desktop.
Save thattommyhall/3707fdf6021b28e38545 to your computer and use it in GitHub Desktop.
(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