Skip to content

feat: add C implementation for stats/base/dists/lognormal/cdf#10809

Open
bhargava-d16 wants to merge 3 commits intostdlib-js:developfrom
bhargava-d16:feat-lognormal-cdf-c-implementation
Open

feat: add C implementation for stats/base/dists/lognormal/cdf#10809
bhargava-d16 wants to merge 3 commits intostdlib-js:developfrom
bhargava-d16:feat-lognormal-cdf-c-implementation

Conversation

@bhargava-d16
Copy link
Copy Markdown
Contributor


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 status: passed
  • task: lint_package_json status: passed
  • task: lint_repl_help status: na
  • 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: passed
  • task: lint_python status: na
  • task: lint_r status: na
  • task: lint_c_src status: missing_dependencies
  • task: lint_c_examples status: missing_dependencies
  • task: lint_c_benchmarks status: missing_dependencies
  • 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 ---

Resolves #3747

Description

What is the purpose of this pull request?

This pull request:

  • adds C implementation for @stdlib/stats/base/dists/lognormal/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.".


@stdlib-js/reviewers

Signed-off-by: Bhargav Dabhade <bhargava2005dabhade@gmail.com>

---
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
    status: passed
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: na
  - 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: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: missing_dependencies
  - task: lint_c_examples
    status: missing_dependencies
  - task: lint_c_benchmarks
    status: missing_dependencies
  - 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
---
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Mar 8, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

stdlib-bot commented Mar 8, 2026

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/lognormal/cdf $\color{green}281/281$
$\color{green}+0.00%$
$\color{green}23/23$
$\color{green}+0.00%$
$\color{green}4/4$
$\color{green}+0.00%$
$\color{green}281/281$
$\color{green}+0.00%$

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

Copy link
Copy Markdown
Member

@Neerajpathak07 Neerajpathak07 left a comment

Choose a reason for hiding this comment

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

@bhargava-d16 Overall this looks great. Just a few comments and nitpicks.

Comment on lines +95 to +99
static double benchmark( void ) {
double elapsed;
double sigma[ 100 ];
double mu[ 100 ];
double x[ 100 ];
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.

Suggested change
static double benchmark( void ) {
double elapsed;
double sigma[ 100 ];
double mu[ 100 ];
double x[ 100 ];
static double benchmark( void ) {
double sigma[ 100 ];
double mu[ 100 ];
double x[ 100 ];
double elapsed;

Ordering by length

Comment on lines +45 to +47
x = uniform( 100, 0.1, 20.0, opts );
mu = uniform( 100, -5.0, 5.0, opts );
sigma = uniform( 100, EPS, 5.0, opts );
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.

Normally what we want to do is align the C benchmark ranges to the corresponding range values opted in JS benchmark. Maybe we can follow it here as well!!!

Comment on lines +54 to +56
x = uniform( 100, 0.1, 20.0, opts );
mu = uniform( 100, -5.0, 5.0, opts );
sigma = uniform( 100, EPS, 5.0, opts );
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.

Same comment here as well. You can align these ranges to the ones used in benchmark.js

t.end();
});

tape( 'the function evaluates the cdf for `x` given positive `mu`', opts, function test( t ) {
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.

nit: If possible could you pls modify these test cases to test against fixtures drawn from a singular json file namely data.json also to use isAlmostSameValue. This is also expected to be updated throughout the test files.

you can also take a look at:- https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/%40stdlib/stats/base/dists/wald/pdf/test/test.pdf.js#L197

for ( i = 0; i < 25; i++ ) {
x = random_uniform( 0.0, 10.0 );
mu = random_uniform( -5.0, 5.0 );
sigma = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
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.

Corresponding JS example does not use eps in it's range values. Might be better to update it here as well.
Meaning you'll also have to update the documentation and the manifest eventually.

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.

@github-actions github-actions Bot mentioned this pull request Mar 25, 2026
Signed-off-by: Bhargav Dabhade <bhargava2005dabhade@gmail.com>

---
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
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: missing_dependencies
  - task: lint_c_benchmarks
    status: missing_dependencies
  - 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
---
---
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
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: missing_dependencies
  - 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
---
@bhargava-d16
Copy link
Copy Markdown
Contributor Author

@Planeshifter I have made the suggested changes. Please let me know if any further changes are required.

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. Needs Review A pull request which needs code review. 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/lognormal/cdf

3 participants