Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect percentile calculation #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/com/stuartsierra/frequencies.clj
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,15 @@
(defn percentiles
"Returns a map of percentile values from the frequency map. Argument
'percentiles' is a collection of percentile targets, which will be
keys in the returned map. For example, a percentiles argument of
[25 50 99.9] would return a map containing the 25th, 50th (median),
keys in the returned map. For example, a percentiles argument of
[25 50 99.9] would return a map containing the 25th, 50th (median),
and 99.9th percentile."
[freq-map percentiles]
(percentiles* (ensure-sorted freq-map)
percentiles
(sample-count freq-map)))
(let [sorted-freq-map (ensure-sorted freq-map)
num-samples (sample-count sorted-freq-map)]
(percentiles* sorted-freq-map
percentiles
num-samples)))

(defn variance*
"Like 'variance' but takes the mean and sample count as arguments
Expand Down