Skip to content

feat: add stats/base/dists/anglit/stdev#11489

Open
Om-A-osc wants to merge 1 commit intostdlib-js:developfrom
Om-A-osc:feat/stats-base-dists-anglit-stdev
Open

feat: add stats/base/dists/anglit/stdev#11489
Om-A-osc wants to merge 1 commit intostdlib-js:developfrom
Om-A-osc:feat/stats-base-dists-anglit-stdev

Conversation

@Om-A-osc
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: passed
  • task: lint_javascript_src status: passed
  • task: lint_javascript_cli status: na
  • task: lint_javascript_examples status: passed
  • task: lint_javascript_tests status: passed
  • task: lint_javascript_benchmarks status: passed
  • task: lint_python status: passed
  • task: lint_r status: na
  • task: lint_c_src status: passed
  • task: lint_c_examples status: passed
  • task: lint_c_benchmarks status: passed
  • task: lint_c_tests_fixtures status: na
  • task: lint_shell status: na
  • task: lint_typescript_declarations status: passed
  • task: lint_typescript_tests status: passed
  • task: lint_license_headers status: passed

Progresses #9960.

Description

What is the purpose of this pull request?

This pull request:

  • adds stats/base/dists/anglit/stdev
  • implements the standard deviation for the Anglit distribution
  • includes unit tests and documentation
  • follows stdlib conventions and project structure

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?

Implementation follows existing distribution mode modules and adheres to stdlib coding standards.

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
  • Test/benchmark generation
  • Documentation
  • Research and understanding

Disclosure

N/A


@stdlib-js/reviewers

---
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: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: passed
  - task: lint_r
    status: na
  - task: lint_c_src
    status: passed
  - task: lint_c_examples
    status: passed
  - task: lint_c_benchmarks
    status: passed
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
@Om-A-osc Om-A-osc requested a review from a team April 16, 2026 19:37
@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 16, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/anglit/stdev $\color{green}181/181$
$\color{green}+100.00%$
$\color{green}9/9$
$\color{green}+100.00%$
$\color{green}2/2$
$\color{green}+100.00%$
$\color{green}181/181$
$\color{green}+100.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.

@Om-A-osc Thank you for working on this!!! Left out a few comments.

static double benchmark( void ) {
double elapsed;
double sigma[ 100 ];
double mu[ 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
double mu[ 100 ];
static double benchmark( void ) {
double sigma[ 100 ];
double mu[ 100 ];
double elapsed;

Ordering by length

// TypeScript Version: 4.1

/**
* Returns the standard deviation for an anglit distribution with location `mu` and scale `sigma`.
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
* Returns the standard deviation for an anglit distribution with location `mu` and scale `sigma`.
* Returns the standard deviation for an anglit distribution with location parameter `mu` and scale parameter `sigma`.

Feel free to update the description wherever relevant throughout the PR if you feel this makes more sense.

NaN

See Also
--------
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
--------
--------


// VARIABLES //

// sqrt( (π²/16) - (1/2) ):
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
// sqrt( (π²/16) - (1/2) ):
// sqrt( (π²/16) - (1/2) )

#include "stdlib/stats/base/dists/anglit/stdev.h"
#include "stdlib/math/base/assert/is_nan.h"

static const double STDLIB_ANGLIT_STDEV_CONST = 0.3418336950449515; // sqrt( (π²/16) - (1/2) )
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.

Using this const here would be acceptable as per discussed in the Office Hours conducted on April 14th.

Suggested change
static const double STDLIB_ANGLIT_STDEV_CONST = 0.3418336950449515; // sqrt( (π²/16) - (1/2) )
// sqrt( (π²/16) - (1/2) )
static const double STDEV_CONST = 0.3418336950449515;

Let's stay consist with the variable name as per used in the JS implementation. Also something which we closely follow for special math functions. Re:- powf

stdlib_base_is_nan( sigma ) ||
sigma <= 0.0
) {
return 0.0/0.0; // NaN
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
return 0.0/0.0; // NaN
return 0.0 / 0.0; // NaN


# Arguments

* `mean`: mean parameter (mu)
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
* `mean`: mean parameter (mu)
* `mean`: location parameter (mu)

mu here is a location parameter not mean.

# Examples

``` python
python> mean = rand(1000) * 10.0 - 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.

Same comment.

"""Generate fixture data."""
mean = rand(1000) * 10.0 - 5.0
scale = rand(1000) * 10.0 + 1.0
gen(mean, scale, "data.json")
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.

Would be better to do a clean-up on this runner file.


The [standard deviation][stdev] for an [anglit][anglit-distribution] random variable with location parameter `mu` and scale parameter `sigma` is

<!-- <equation class="equation" label="eq:anglit_stdev" align="center" raw="\operatorname{SD}(X) = \sigma \sqrt{\left({\frac{\pi^{2}}{16}}-\frac{1}{2}\right)}" alt="Standard deviation for an anglit distribution."> -->
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.

While previewing the markdown documentation the equation is not generated here properly. Mind fixing that as well.
Re:-

Image

@Neerajpathak07 Neerajpathak07 added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Changes Pull request which needs changes before being merged. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants