Skip to content

feat: add stats/base/dists/log-logistic/cdf#11283

Merged
Planeshifter merged 4 commits into
stdlib-js:developfrom
parthodas23:feat/stat-base-dists-log-logistic-cdf
Jul 5, 2026
Merged

feat: add stats/base/dists/log-logistic/cdf#11283
Planeshifter merged 4 commits into
stdlib-js:developfrom
parthodas23:feat/stat-base-dists-log-logistic-cdf

Conversation

@parthodas23

Copy link
Copy Markdown
Contributor

Resolves none

Description

What is the purpose of this pull request?

This pull request:

  • feat: add stats/base/dists/log-logistic/cdf

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

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.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

{{TODO: add disclosure if applicable}}


@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 Apr 3, 2026
@stdlib-bot

stdlib-bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/log-logistic/cdf $\\color{green}311/311$
$\\color{green}+0.00\\%$
$\\color{green}29/29$
$\\color{green}+0.00\\%$
$\\color{green}4/4$
$\\color{green}+0.00\\%$
$\\color{green}311/311$
$\\color{green}+0.00\\%$

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

@parthodas23 parthodas23 force-pushed the feat/stat-base-dists-log-logistic-cdf branch from 4899765 to 75d869b Compare April 3, 2026 11:21
@github-actions github-actions Bot mentioned this pull request Apr 3, 2026
@parthodas23 parthodas23 force-pushed the feat/stat-base-dists-log-logistic-cdf branch 2 times, most recently from 72ff6d2 to c66c194 Compare April 5, 2026 10:19
@rautelaKamal

Copy link
Copy Markdown
Contributor

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:
xb = stdlib_base_pow( x / alpha, beta );
return xb / ( 1.0 + xb );

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:
return 1.0 / ( 1.0 + stdlib_base_pow( alpha / x, beta ) );

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.

@kgryte

kgryte commented Apr 6, 2026

Copy link
Copy Markdown
Member

@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.

@parthodas23 parthodas23 force-pushed the feat/stat-base-dists-log-logistic-cdf branch from c66c194 to e0d3687 Compare April 6, 2026 10:21
@parthodas23

Copy link
Copy Markdown
Contributor Author

@kgryte I check SciPy's implementation (_continuous_distns.py) and @rautelaKamal was correct. I've updated src/main.c to use 1.0 / (1.0 + pow(alpha / x, beta)) to be consistent with SciPy.

@parthodas23 parthodas23 force-pushed the feat/stat-base-dists-log-logistic-cdf branch 2 times, most recently from b068d1e to 63392b6 Compare April 6, 2026 10:41
parthodas23 and others added 2 commits July 5, 2026 00:31
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
---
@Planeshifter Planeshifter force-pushed the feat/stat-base-dists-log-logistic-cdf branch from 63392b6 to 55c9bcf Compare July 5, 2026 05:33
@Planeshifter Planeshifter requested a review from a team July 5, 2026 05:33
Comment thread lib/node_modules/@stdlib/stats/base/dists/log-logistic/cdf/src/addon.c Outdated
Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Planeshifter
Planeshifter previously approved these changes Jul 5, 2026

@Planeshifter Planeshifter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thanks!

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Jul 5, 2026
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jul 5, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

PR Commit Message

feat: add `stats/base/dists/log-logistic/cdf`

PR-URL: https://github.com/stdlib-js/stdlib/pull/11283
Ref: https://github.com/stdlib-js/stdlib/issues/175

Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>

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

Comment thread lib/node_modules/@stdlib/stats/base/dists/log-logistic/cdf/examples/index.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/log-logistic/cdf/examples/c/example.c Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/log-logistic/cdf/README.md Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/log-logistic/cdf/README.md Outdated
Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
@Planeshifter Planeshifter merged commit e3c68d4 into stdlib-js:develop Jul 5, 2026
13 checks passed
@stdlib-bot stdlib-bot removed the Ready To Merge A pull request which is ready to be merged. label Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants