-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Adding the chi square distribution #15799
Conversation
Thanks, good catch. I'll fix and resubmit later today (/or early tomorrow).
Any other comments to address?
T
…On Mon, Mar 22, 2021, 17:49 Jinlin Zhang ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In presto-docs/src/main/sphinx/functions/math.rst
<#15799 (comment)>:
> @@ -85,6 +85,18 @@ Mathematical Functions
The a, b parameters must be positive real numbers and value v must be a real value.
The value v must lie on the interval [0, 1].
+.. function:: inverse_chisquared_cdf(df, p) -> double
+
+ Compute the inverse of the Chi-square cdf with given df (degrees of freedom) parameter for the cumulative
+ probability (p): P(N < n). The the df parameter must be positive real values.
Please remove the extra "the".
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15799 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHOJBVSDAHCTEXAS2EUFIDTE5RJ3ANCNFSM4Y6DLR6Q>
.
|
8f0545c
to
cb10950
Compare
Hey @v-jizhang , Details: Cheers, |
cb10950
to
be5b6a3
Compare
(rebased) |
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.
Looks good to me.
be5b6a3
to
46fd3df
Compare
@@ -85,6 +85,18 @@ Mathematical Functions | |||
The a, b parameters must be positive real numbers and value v must be a real value. | |||
The value v must lie on the interval [0, 1]. | |||
|
|||
.. function:: inverse_chi_squared_cdf(df, p) -> double |
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.
Please put the function documentation in alphabetical order. The cdf documentation were in wrong places. You don't need to fix them in this PR, just make sure the new function documentations are added at the correct place.
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.
Given that we intend to add more distributions (t, F, Gamma, etc.). I think a better approach is to have a dedicated section in the doc called "Probability distributions" (similar to how the doc currently has "Statistical Functions", "Trigonometric Functions", etc.)
I can do it in a separate diff before-or-after we finish adding all the distribution functions. Makes sense?
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.
Makes sense. You can add a separate PR to refactor the documentation first, and rebase this PR on top of that one. Or if you prefer to do that afterwards, let's put these functions in the conventional order for this PR and modify it later.
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.
Looks good. Please fix the nits. Thanks for contributing!
presto-main/src/main/java/com/facebook/presto/operator/scalar/MathFunctions.java
Outdated
Show resolved
Hide resolved
Thanks Rongrong!
I'll fix it early next week and will ping once it's done.
T
…On Fri, Mar 26, 2021, 21:19 Rongrong Zhong ***@***.***> wrote:
***@***.**** commented on this pull request.
Looks good. Please fix the nits. Thanks for contributing!
------------------------------
In
presto-main/src/main/java/com/facebook/presto/operator/scalar/MathFunctions.java
<#15799 (comment)>:
> @@ -704,6 +705,32 @@ public static double betaCdf(
return distribution.cumulativeProbability(value);
}
+ @description("inverse of ChiSquared cdf given df parameter and probability")
+ @ScalarFunction
+ @SqlType(StandardTypes.DOUBLE)
+ public static double inverseChiSquaredCdf(
+ @SqlType(StandardTypes.DOUBLE) double df,
+ @SqlType(StandardTypes.DOUBLE) double p)
+ {
+ checkCondition(p >= 0 && p <= 1, INVALID_FUNCTION_ARGUMENT, "p must be in the interval [0, 1]");
+ checkCondition(df > 0, INVALID_FUNCTION_ARGUMENT, "df must be > 0");
must be greater than 0
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15799 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHOJBTDFXQ3EN2R5SLKR7TTFTF2ZANCNFSM4Y6DLR6Q>
.
|
46fd3df
to
eb3b130
Compare
@rongrong - thanks for the diff review. Assuming it's all good, please move forward with merging this diff. Thanks! |
Hey @rongrong :) |
Great.
I'll modify this diff (in the coming two hours) to follow your proposed
order, and will submit a new diff to create a new section in the doc in tge
coming weeks.
Will update soon.
T
…On Wed, Apr 14, 2021, 21:14 Rongrong Zhong ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In presto-docs/src/main/sphinx/functions/math.rst
<#15799 (comment)>:
> @@ -85,6 +85,18 @@ Mathematical Functions
The a, b parameters must be positive real numbers and value v must be a real value.
The value v must lie on the interval [0, 1].
+.. function:: inverse_chi_squared_cdf(df, p) -> double
Makes sense. You can add a separate PR to refactor the documentation
first, and rebase this PR on top of that one. Or if you prefer to do that
afterwards, let's put these functions in the conventional order for this PR
and modify it later.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15799 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHOJBVTGUNSWW5HGSIEM3DTIXLOVANCNFSM4Y6DLR6Q>
.
|
a3f0118
to
cf73590
Compare
Hey @rongrong - I've now:
Please let me know if this now works. Once Merged, I'll update the other contributors of all the learnings gained in this PR for me, and we'll proceed with preparing more diffs. Yours, |
cf73590
to
d80da1c
Compare
Adding the chi square distribution, which is central to many statistical procedures (https://en.wikipedia.org/wiki/Chi-square_distribution) (#15798)
Test plan (adding unit-tests)
Following the diff template of: https://github.com/prestodb/presto/pull/11981/files