News for hackers. Stuff that matters.
Re:How percentile approximation works and why it's more usef... by cyral on Tuesday September 14, 2021 @12:51PM (#28527475)
There are some newer data structures that take this to the next level such as T-Digest[1], which remains extremely accurate even when determining percentiles at the very tail end (like 99.999%)

[1]: https://arxiv.org/pdf/1902.04023.pdf / https://github.com/tdunning/t-digest

Re:How percentile approximation works and why it's more usef... by djk447 on Tuesday September 14, 2021 @01:06PM (#28527673)
NB: Post author here.

Yeah, that was one of the reasons we chose it as one of the ones to implement, seemed like that was a really interesting tradeoff, we also used uddsketch[1] which provides relative error guarantees, which is pretty nifty. We thought they provided different enough tradeoffs that we wanted to implement both.

[1]: https://arxiv.org/abs/1908.10693

Re:How percentile approximation works and why it's more usef... by vvern on Tuesday September 14, 2021 @01:41PM (#28528130)
Is it using https://github.com/tvondra/tdigest under the hood, or a separate implementation?
Re:How percentile approximation works and why it's more usef... by mfreed on Tuesday September 14, 2021 @02:19PM (#28528617)
If folks are interested:

https://github.com/timescale/timescaledb-toolkit/blob/main/e...

(The TimescaleDB Toolkit is also implemented in Rust)

Re:How percentile approximation works and why it's more usef... by rogers18445 on Wednesday September 15, 2021 @03:41PM (#28543460)
Facebook seems to have an even better performance implementation using sqrt. Might make sense to port that over to Rust. https://github.com/facebook/folly/blob/master/folly/stats/TD...
Re:How percentile approximation works and why it's more usef... by Lockerman on Tuesday September 14, 2021 @01:43PM (#28528142)
a separate implementation
Re:How percentile approximation works and why it's more usef... by _0ffh on Wednesday September 15, 2021 @10:30AM (#28539515)
Hi, in an unrelated nitpick: The relative error should be calculated by dividing the error by the true value, not by it's approximation. Still, very nice writeup!
Re:How percentile approximation works and why it's more usef... by djk447 on Wednesday September 15, 2021 @12:14PM (#28540946)
Thanks! messed up the formula but had it right in the text :( Fixed now.
Re:How percentile approximation works and why it's more usef... by jeremysalwen on Wednesday September 15, 2021 @02:05AM (#28535772)
Not an expert on this topic but I noticed that the KLL algorithm (published in 2016) was not mentioned in this thread, which provides theoretically optimal performance for streaming quantiles with guaranteed worst case performance: http://courses.csail.mit.edu/6.854/20/sample-projects/B/stre... (And is pretty fast in practice).
Re:How percentile approximation works and why it's more usef... by djk447 on Wednesday September 15, 2021 @08:21AM (#28538141)
NB: Post author here.

Interesting will have to take a look! Thanks for sharing!

Re:How percentile approximation works and why it's more usef... by riskneutral on Tuesday September 14, 2021 @03:27PM (#28529780)
Also relevant: Single-Pass Online Statistics Algorithms

[1] http://www.numericalexpert.com/articles/single_pass_stat/

Re:How percentile approximation works and why it's more usef... by breuleux on Tuesday September 14, 2021 @01:51PM (#28528246)
That's pretty neat! Can these be used to efficiently compute rolling percentiles (over windows of the data), or just incremental?
Re:How percentile approximation works and why it's more usef... by WireBaron on Tuesday September 14, 2021 @02:05PM (#28528448)
The UDDSketch (default) implementation will allow rolling percentiles, though we still need a bit of work on our end to support it. There isn't a way to do this with TDigest however.
Re:How percentile approximation works and why it's more usef... by jeffbee on Tuesday September 14, 2021 @03:18PM (#28529612)
Sure there is. You simply maintain N phases of digests, and every T time you evict a phase and recompute the summary (because T-digests are easily merged).
Re:How percentile approximation works and why it's more usef... by djk447 on Tuesday September 14, 2021 @03:53PM (#28530146)
I think this would be a tumbling window rather than a true "rolling" tdigest. I suppose you could decrement the buckets, but it gets a little weird as splits can't really be unsplit. The tumbling window one would probably work, though Tdigest is a little weird on merge etc as it's not completely deterministic with respect to ordering and merging (Uddsketch is) so it's likely you get something that is more than good enough, but wouldn't be the same as if you just calculated it directly so it gets a little confusing and difficult.

(NB: Post author here).

Re:How percentile approximation works and why it's more usef... by cyral on Tuesday September 14, 2021 @04:28PM (#28530613)
This is what I do, it's not a true rolling digest but it works well enough for my purposes.
Re:How percentile approximation works and why it's more usef... by fotta on Tuesday September 14, 2021 @02:49PM (#28529159)
yep I had to implement t-digest in a monitoring library. another alternative (although older) that the prometheus libraries use is CKMS quantiles [0].

[0] http://dimacs.rutgers.edu/~graham/pubs/papers/bquant-icde.pd...

Re:How percentile approximation works and why it's more usef... by convolvatron on Tuesday September 14, 2021 @12:53PM (#28527504)
i think the new ones started wtih Greenwald-Khanna. but i definately agree - p^2 can be a little silly and misleading. in particular it is really poor at finding those little modes on the tail that correspond to interesting system behaviours.
Re:How percentile approximation works and why it's more usef... by cyral on Tuesday September 14, 2021 @12:56PM (#28527538)
That sounds familiar, I remember reading about Greenwald-Khanna before I found T-Digest after I ran into the "how to find a percentile of a massive data set" problem myself.