Skip to content

Instantly share code, notes, and snippets.

@slipset
Created August 8, 2014 16:26
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 slipset/45c51c41943195ce3110 to your computer and use it in GitHub Desktop.
Save slipset/45c51c41943195ce3110 to your computer and use it in GitHub Desktop.
(defn percentile [xs n]
(let [idx (Math/floor (* (count xs) (/ n 100)))]
(nth (sort xs) idx)))
(defn percentiles [xs]
(let [p (partial percentile xs)]
(into {} (map (juxt (comp keyword str) p) [50 90 95 99]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment