10BC0 feat: add `stats/incr/wvariance` incremental weighted variance by Om-A-osc · Pull Request #9958 · stdlib-js/stdlib · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@Om-A-osc
Copy link
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: na
  • 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: passed
  • task: lint_license_headers status: passed ---

Resolves #46.

Description

What is the purpose of this pull request?

This pull request:

  • Adds an incremental accumulator for computing the weighted variance.
  • Implements a numerically stable, one-pass algorithm based on the weighted Welford method.
  • Computes the unnormalized second central moment incrementally and normalizes by the total weight.
  • Adds tests validating correctness against batch-computed weighted variance.
  • Adds documentation describing the underlying mathematics and usage.

The incremental update follows the weighted Welford formulation:

welfordvariance

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.

  • Test fixtures were generated using Python with NumPy to compute batch weighted variance for prefix sequences.
  • Tests, benchmarks, and README documentation have been added or updated as appropriate.
  • Contributing guidelines were read and followed.

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

Disclosure

No AI assistance was used in the implementation, tests, or documentation.


@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: na
  - 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: passed
  - 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. labels Jan 28, 2026
@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr $\color{red}15001/21274$
$\color{green}+70.51%$
$\color{green}211/211$
$\color{green}+100.00%$
$\color{red}0/116$
$\color{green}+0.00%$
$\color{red}15001/21274$
$\color{green}+70.51%$
stats/incr/wvariance $\color{green}202/202$
$\color{green}+100.00%$
$\color{green}16/16$
$\color{green}+100.00%$
$\color{green}2/2$
$\color{green}+100.00%$
$\color{green}202/202$
$\color{green}+100.00%$

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

@Om-A-osc
Copy link
Contributor Author

@kgryte Issue #46 has officially reached legendary status (≈10 years 😄).
I’ve implemented the requested feature would love your review whenever you have time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 stats/incr/wvariance

2 participants

0