-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
Reducers: Add in basic Percentile Support #85554
Conversation
@@ -28,6 +28,106 @@ export enum ReducerID { | |||
allIsNull = 'allIsNull', | |||
allValues = 'allValues', | |||
uniqueValues = 'uniqueValues', | |||
p1 = 'p1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooof, @timlevett you're right, this is rough! 😊 We could remove the p values and replace it with something like this?
function generatePercentiles() {
const percentiles: { [key: string]: string } = {};
for (let i = 1; i <= 99; i++) {
percentiles[`p${i}`] = `p${i}`;
}
return percentiles;
}
export enum ReducerID {
...generatePercentiles(),
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah clever, i didn't know you could do that with an enum! TIL. Will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do this but enum doesn't allow dynamic additions :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TS, c'mon! Well, we tried! ;)
for (let i = 1; i < 100; i++) { | ||
const percentile = i / 100; | ||
const id = `p${i}` as ReducerID; | ||
const nth = (n: number) => n>3&&n<21?"th":n%10===1?"st":n%10===2?"nd":n%10===3?"rd":"th"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can thank the internet for that one 😂
…alculation is more accurate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
What is this feature?
As a user I want to be able to quickly calculate various percentiles on my data, both in group by transformations and in legends, or wherever else reducers are used.
Screenshare.-.2024-04-03.1_11_18.PM.mp4
Update: Based off of offline chatter, changed to generate p1 through p99.
Why do we need this feature?
It's so nice to be able to understand percentiles as they a much better statistic than mean (averages). There is a joke, if Bill Gates walks into a bar, on average everyone is a millionaire. Its a mean joke... Having percentiles will help reduce (no pun intended) any misguidance that mean is giving people.
Who is this feature for?
Stats nerds, or anyone who is interested in learning better estimations.
Which issue(s) does this PR fix?:
Fixes #
Special notes for your reviewer:
Please check that: