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

WIP: experimental building of histograms from tdigest #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tvondra
Copy link
Owner

@tvondra tvondra commented Aug 9, 2020

This implements two simple SQL functions, building different types of
histograms from a t-digest. Equi-width histograms are the "usual" type
with each bin covering about 1/N of the domain, while equi-height
histograms have bins representing the same fraction of the data.

The functions are fairly trivial SQL functions, calculating boundaries
on either the domain or frequency, and then computing the other values
using the t-digest.

I'm not sure how accurate the histograms are - considering how t-digests
work, the bins at the ends should be the fine while the bins in the
middle could be somewhat less accurate.

One thing this made me realize is the extension only provides aggregate
functions, so when we need to work with t-digests in non-aggregate
contexts it's necessary to do unnecessary groupings etc. Might be handy
to provide some non-aggregate functions to make that unnecessary.

This implements two simple SQL functions, building different types of
histograms from a t-digest. Equi-width histograms are the "usual" type
with each bin covering about 1/N of the domain, while equi-height
histograms have bins representing the same fraction of the data.

The functions are fairly trivial SQL functions, calculating boundaries
on either the domain or frequency, and then computing the other values
using the t-digest.

I'm not sure how accurate the histograms are - considering how t-digests
work, the bins at the ends should be the fine while the bins in the
middle could be somewhat less accurate.

One thing this made me realize is the extension only provides aggregate
functions, so when we need to work with t-digests in non-aggregate
contexts it's necessary to do unnecessary groupings etc. Might be handy
to provide some non-aggregate functions to make that unnecessary.
@sporty81
Copy link

sporty81 commented Aug 10, 2020

These look pretty good to me at first glance, and from my testing of them. I will spend some more time thinking about how I would want to build out histograms for my own usage and how this all relates. Thank you!

@tvondra tvondra force-pushed the master branch 2 times, most recently from 2055fae to 168482f Compare May 8, 2021 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Functions to compute histograms from the approximated CDF
2 participants