⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@DivyanshuVortex
Copy link
Contributor

Resolves : none.

Description

What is the purpose of this pull request?

This pull request:

  • feat: add stats/base/ndarray/dvariancech

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

  • none

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

---
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: na
  - 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 10, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 10, 2026

Coverage Report

Package Statements Branches Functions Lines
stats/base/ndarray/dvariancech $\color{green}124/124$
$\color{green}+0.00%$
$\color{green}3/3$
$\color{green}+0.00%$
$\color{green}1/1$
$\color{green}+0.00%$
$\color{green}124/124$
$\color{green}+0.00%$

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

Comment on lines 2 to 4
{{alias}}( arrays )
Computes the variance of a one-dimensional single-precision floating-point
ndarray using a one-pass trial mean algorithm.
Copy link
Member

Choose a reason for hiding this comment

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

This says "single-precision" but it should say "double-precision" since this is a d-prefixed package working with float64 data.

Suggested change
{{alias}}( arrays )
Computes the variance of a one-dimensional single-precision floating-point
ndarray using a one-pass trial mean algorithm.
{{alias}}( arrays )
Computes the variance of a one-dimensional double-precision floating-point
ndarray using a one-pass trial mean algorithm.

// MODULES //

var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
Copy link
Member

Choose a reason for hiding this comment

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

This should use isnan (double-precision) instead of isnanf (single-precision) since this package operates on float64 data. You can check similar packages like @stdlib/stats/base/ndarray/variancech or @stdlib/stats/base/ndarray/dstdev for reference.

Suggested change
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );


var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var float64Array = require( '@stdlib/array/float64' );
Copy link
Member

Choose a reason for hiding this comment

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

Constructor variables should use PascalCase per stdlib style guidelines.

Suggested change
var float64Array = require( '@stdlib/array/float64' );
var Float64Array = require( '@stdlib/array/float64' );

---
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: passed
  - task: lint_javascript_src
    status: na
  - 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: 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: na
  - task: lint_license_headers
    status: passed
---
Comment on lines 56 to 69
function variancech( arrays ) {
var correction;
var x;

x = arrays[ 0 ];
correction = ndarraylike2scalar( arrays[ 1 ] );

return strided( numelDimension( x, 0 ), correction, getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len
}


// EXPORTS //

module.exports = variancech;
Copy link
Member

Choose a reason for hiding this comment

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

The function name should be dvariancech to match the package name.


/// <reference types="@stdlib/types"/>

import { typedndarray } from '@stdlib/types/ndarray';
Copy link
Member

Choose a reason for hiding this comment

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

Missing float64ndarray import. Comparing to the reference dstdev package, this should be:

Suggested change
import { typedndarray } from '@stdlib/types/ndarray';
import { float64ndarray, typedndarray } from '@stdlib/types/ndarray';

* var v = dvariancech( [ x, correction ] );
* // returns ~4.3333
*/
declare function dvariancech<T extends typedndarray<number> = typedndarray<number>>( arrays: [ T, T ] ): number;
Copy link
Member

Choose a reason for hiding this comment

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

The first array element should be typed as float64ndarray since this is a double-precision function (the d prefix). Comparing to dstdev:

Suggested change
declare function dvariancech<T extends typedndarray<number> = typedndarray<number>>( arrays: [ T, T ] ): number;
declare function dvariancech<T extends typedndarray<number> = typedndarray<number>>( arrays: [ float64ndarray, T ] ): number;

---
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: passed
  - 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: 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
---
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.

3 participants