Created
August 8, 2014 16:26
-
-
Save slipset/45c51c41943195ce3110 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 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