Skip to content

feat(velox): Add Student's t distribution functions (t_cdf and inverse_t_cdf)#15234

Closed
talgalili wants to merge 1 commit intofacebookincubator:mainfrom
talgalili:export-D85123230
Closed

feat(velox): Add Student's t distribution functions (t_cdf and inverse_t_cdf)#15234
talgalili wants to merge 1 commit intofacebookincubator:mainfrom
talgalili:export-D85123230

Conversation

@talgalili
Copy link
Copy Markdown
Contributor

Summary:
This change adds C++ support for Student's t distribution statistical functions to Velox, complementing the Java/Presto implementation in D85004073.

The t-distribution is commonly used in statistical hypothesis testing, particularly when dealing with small sample sizes or when the population standard deviation is unknown. These functions enable users to perform statistical analysis directly within SQL queries.

Functions Added:

  • t_cdf(df, value): Computes the cumulative probability P(N < value) for a given degrees of freedom (df) and value
  • inverse_t_cdf(df, p): Computes the inverse CDF (quantile function) for a given degrees of freedom and probability p

Implementation Details:

  • Uses Boost.Math's students_t_distribution for accurate calculations
  • Follows the same patterns as existing probability functions (chi-squared, F-distribution)
  • Includes proper validation for input parameters (df must be positive, probability must be in [0, 1])

Files Changed:

  1. Probability.h: Added TCDFFunction and InverseTCDFFunction template structs
  2. ProbabilityTrigonometricFunctionsRegistration.cpp: Registered both functions
  3. ProbabilityTest.cpp: Added comprehensive unit tests covering edge cases and error handling
  4. math.rst: Updated documentation with function signatures and parameter descriptions

Differential Revision: D85123230

@netlify
Copy link
Copy Markdown

netlify bot commented Oct 21, 2025

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit e9ce7a6
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/68fb2c30ec87e200085eb8f0

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Oct 21, 2025

@talgalili has exported this pull request. If you are a Meta employee, you can view the originating Diff in D85123230.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 21, 2025
@talgalili talgalili force-pushed the export-D85123230 branch 2 times, most recently from 3d83036 to 445fd27 Compare October 22, 2025 19:38
@talgalili
Copy link
Copy Markdown
Contributor Author

Dear @steveburnett, @hantangwangd and @feilong-liu - this diff is a followup to this one which you've reviewed+accepted+merged:
prestodb/presto#26363

Could you please review this PR as well? Thanks!

Copy link
Copy Markdown
Collaborator

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (docs)

Pull branch, local doc build, looks good.

@talgalili
Copy link
Copy Markdown
Contributor Author

@feilong-liu could you please merge this as well (like you did prestodb/presto#26363) ? Thanks upfront!

…e_t_cdf) (facebookincubator#15234)

Summary:

This change adds C++ support for Student's t distribution statistical functions to Velox, complementing the Java/Presto implementation in D85004073.

The t-distribution is commonly used in statistical hypothesis testing, particularly when dealing with small sample sizes or when the population standard deviation is unknown. These functions enable users to perform statistical analysis directly within SQL queries.

**Functions Added:**
- `t_cdf(df, value)`: Computes the cumulative probability P(N < value) for a given degrees of freedom (df) and value
- `inverse_t_cdf(df, p)`: Computes the inverse CDF (quantile function) for a given degrees of freedom and probability p

**Implementation Details:**
- Uses Boost.Math's `students_t_distribution` for accurate calculations
- Follows the same patterns as existing probability functions (chi-squared, F-distribution)
- Includes proper validation for input parameters (df must be positive, probability must be in [0, 1])

**Files Changed:**
1. `Probability.h`: Added TCDFFunction and InverseTCDFFunction template structs
2. `ProbabilityTrigonometricFunctionsRegistration.cpp`: Registered both functions
3. `ProbabilityTest.cpp`: Added comprehensive unit tests covering edge cases and error handling
4. `math.rst`: Updated documentation with function signatures and parameter descriptions

Differential Revision: D85123230
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Oct 26, 2025

@talgalili has imported this pull request. If you are a Meta employee, you can view this in D85123230.

Copy link
Copy Markdown
Contributor

@HeidiHan0000 HeidiHan0000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the functions to both Presto Java and Velox!

@meta-codesync meta-codesync bot closed this in b9bc9fd Oct 30, 2025
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Oct 30, 2025

@talgalili merged this pull request in b9bc9fd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants