ztellman/narrator

Quantiles problem: rounding?

Closed this issue · 3 comments

tjg commented
(query-seq n/quantiles (range 1000))

;; From README:
=> {0.999 998.001, 0.99 989.01, 0.95 949.05, 0.9 899.1, 0.5 499.5}

;; But on Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux:
=> {0.999 999.0, 0.99 990.0, 0.95 950.0, 0.9 900.0, 0.5 500.0}

As I understand, the README is correct for the 50th percentile: 499.5. Because the median values in (range 1000) are 499 and 500.

More system info:

[narrator "0.1.0"]
[org.clojure/clojure "1.5.1"]

I can't reproduce those values either. I think this is due to an upgrade in the underlying Q-Digest implementation. Anyway, I'll update the readme to reflect it.

tjg commented

Ah... so is this an approximate, quasi-... operator? (Because otherwise this maybe looks like a bug, not a documentation error; it worked properly before.)

Yes, it's approximate. Doing the same on a stream of a million numbers yields this:

> (query-seq n/quantiles (range 1e6))
{0.999 999805.000191, 0.99 991063.703551, 0.95 950932.602879, 0.9 900735.172607, 0.5 500497.907711}

I've updated the readme to reflect the approximate nature of the operator.