Skip to content

feat: add C implementation for stats/base/dists/chi/logpdf #4527

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

Merged
merged 12 commits into from
Jun 19, 2025

Conversation

AadishJ
Copy link
Contributor

@AadishJ AadishJ commented Jan 4, 2025

Resolves #3492.

Description

What is the purpose of this pull request?

This pull request:

  • Adds a C implementation of the chi logpdf.
  • Includes benchmarks for the C implementation.
  • Provides examples demonstrating the usage of the chi logpdf in C.

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Jan 4, 2025
@AadishJ
Copy link
Contributor Author

AadishJ commented Jan 4, 2025

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jan 4, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jan 4, 2025
Signed-off-by: Aadish Jain <jain.aadishj@gmail.com>
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 4, 2025

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/chi/logpdf $\color{green}307/307$
$\color{green}+100.00\%$
$\color{green}29/29$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}307/307$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

- Fixed header include order in addon.c
- Removed cppcheck suppress directive
- Updated benchmark to use uniform instead of randu
- Fixed spacing in benchmark function call
- Added return 0 in C example
- Adjusted test tolerance for C implementation precision
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Jun 19, 2025
Based on analysis of floating-point precision differences between
JS and C implementations. The 40 EPS tolerance accounts for
accumulated rounding errors in complex calculations involving
ln and gammaln functions.
Explains why 40.0 EPS tolerance is needed due to accumulated
floating-point precision differences in complex calculations
involving ln and gammaln functions.
Changed printf format from 'logf(x;k)' to 'ln(f(x;k))' to match
standard mathematical notation for natural logarithm of PDF.
- Changed printf format from 'logf(x;k)' to 'ln(f(x;k))' for consistency
- Added missing 'return 0;' statement in C example
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Planeshifter
Planeshifter previously approved these changes Jun 19, 2025
Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

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

Should be ready now.

@Planeshifter
Copy link
Member

/stdlib merge

@stdlib-bot stdlib-bot added bot: In Progress Pull request is currently awaiting automation. and removed bot: In Progress Pull request is currently awaiting automation. labels Jun 19, 2025
@Planeshifter
Copy link
Member

/stdlib lint-autofix

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jun 19, 2025
@stdlib-bot
Copy link
Contributor

/stdlib lint-autofix

@Planeshifter, the slash command failed to complete. Please check the workflow logs for details.

View workflow run

@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jun 19, 2025
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Jun 19, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jun 19, 2025

PR Commit Message

feat: add C implementation for `stats/base/dists/chi/logpdf`

PR-URL: https://github.com/stdlib-js/stdlib/pull/4527
Closes: https://github.com/stdlib-js/stdlib/issues/3492

Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
Co-authored-by: stdlib-bot <noreply@stdlib.io>
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Aadish Jain <jain.aadishj@gmail.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>

Please review the above commit message and make any necessary adjustments.

@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jun 19, 2025
@Planeshifter Planeshifter merged commit a79528c into stdlib-js:develop Jun 19, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First PR A pull request resolving a Good First Issue. Ready To Merge A pull request which is ready to be merged. Statistics Issue or pull request related to statistical functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: Add C implementation for @stdlib/stats/base/dists/chi/logpdf
3 participants