feat: add stats/base/dists/log-logistic/cdf#11283
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
4899765 to
75d869b
Compare
72ff6d2 to
c66c194
Compare
|
Hey @parthodas23, pulling this down to review since I am also doing C-ports for distributions. Found a subtle numerical overflow issue in src/main.c around lines 51-52: If x or beta is large enough, xb will overflow to Infinity. In C, calculating Infinity / (1.0 + Infinity) will evaluate to NaN instead of capping at 1.0. You can actually prevent the overflow entirely by inverting the fraction analytically. If you compute it as: Then when x gets huge, alpha / x approaches 0.0, the denominator safely becomes 1.0, and the function returns 1.0 without any overflow or NaN issues. Hope this helps! Happy to review again once you update. |
|
@rautelaKamal How does SciPy compute this quantity? While you are correct regarding rearranging terms, it is not just boundary behavior we need to be concerned about. For example, how does the rearrangement fair in terms of accuracy against reference implementations for the entire domain? Ideally, we'd be consistent with other libraries, such as those in Python/Julia here. |
c66c194 to
e0d3687
Compare
|
@kgryte I check SciPy's implementation (_continuous_distns.py) and @rautelaKamal was correct. I've updated src/main.c to use |
b068d1e to
63392b6
Compare
Evaluate the CDF using whichever algebraically equivalent form keeps
the intermediate power bounded, preventing overflow to infinity (and a
resulting `NaN`) as `x` grows large. Previously, `main.js` and
`factory.js` computed `xb = (x/alpha)^beta; xb/(1+xb)`, which overflows
for large `x` (e.g., `cdf( 1e6, 1.0, 60.0 )` returned `NaN` instead of
`~1.0`), diverging from the C implementation. Both regimes are now
handled consistently across the JS and C paths, and regression tests
covering the large-`x` range are added.
Also fix a `PDF` -> `CDF` typo in the REPL docs and align the README
equation `label` with its `data-equation` identifier.
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown_pkg_readmes
status: passed
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: passed
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
63392b6 to
55c9bcf
Compare
Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com> Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
PR Commit MessagePlease review the above commit message and make any necessary adjustments. |
Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com> Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Resolves none
Description
This pull request:
stats/base/dists/log-logistic/cdfRelated Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
{{TODO: add disclosure if applicable}}
@stdlib-js/reviewers