Skip to content

Instantly share code, notes, and snippets.

@nemosupremo
Created April 1, 2015 21:16
Show Gist options
  • Save nemosupremo/030637d7637ab72975d0 to your computer and use it in GitHub Desktop.
Save nemosupremo/030637d7637ab72975d0 to your computer and use it in GitHub Desktop.
func (h *NumericHistogram) Quantile(q float64) float64 {
count := q * float64(h.total)
for i := range h.bins {
count -= float64(h.bins[i].count)
if count <= 0 {
return h.bins[i].value
}
}
return -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment