Skip to content

feat: add stats/base/ndarray/dcovarmtk #7692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

gururaj1512
Copy link
Member


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

Resolves None

Description

What is the purpose of this pull request?

This pull request:

  • feat: add stats/base/ndarray/dcovarmtk

Related Issues

Does this pull request have any related issues?

This pull request:

  • resolves 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.


@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 Jul 18, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jul 18, 2025

Coverage Report

Package Statements Branches Functions Lines
stats/base/ndarray/dcovarmtk $\color{green}148/148$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}148/148$
$\color{green}+100.00\%$

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

Signed-off-by: Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com>
Signed-off-by: Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com>
Signed-off-by: Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com>
@gururaj1512 gururaj1512 added GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025). labels Jul 20, 2025
@kgryte kgryte added the Feature Issue or pull request for adding a new feature. label Jul 21, 2025
@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Jul 21, 2025
---
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: na
  - 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: na
  - task: lint_license_headers
    status: passed
---
@kgryte kgryte removed the Needs Changes Pull request which needs changes before being merged. label Jul 25, 2025
Comment on lines +135 to +136
4. a zero-dimensional ndarray specifying mean of the first one-dimensional ndarray.
5. a zero-dimensional ndarray specifying mean of the second one-dimensional ndarray.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
4. a zero-dimensional ndarray specifying mean of the first one-dimensional ndarray.
5. a zero-dimensional ndarray specifying mean of the second one-dimensional ndarray.
4. a zero-dimensional ndarray specifying the mean of the first one-dimensional ndarray.
5. a zero-dimensional ndarray specifying the mean of the second one-dimensional ndarray.


1. first one-dimensional input ndarray.
2. second one-dimensional input ndarray.
3. a zero-dimensional ndarray specifying degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [covariance][covariance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the population [covariance][covariance], setting this parameter to `0` is the standard choice (i.e., the provided arrays contain data constituting entire populations). When computing the unbiased sample [covariance][covariance], setting this parameter to `1` is the standard choice (i.e., the provided arrays contain data sampled from larger populations; this is commonly referred to as Bessel's correction).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
3. a zero-dimensional ndarray specifying degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [covariance][covariance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the population [covariance][covariance], setting this parameter to `0` is the standard choice (i.e., the provided arrays contain data constituting entire populations). When computing the unbiased sample [covariance][covariance], setting this parameter to `1` is the standard choice (i.e., the provided arrays contain data sampled from larger populations; this is commonly referred to as Bessel's correction).
3. a zero-dimensional ndarray specifying the degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [covariance][covariance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment and `N` corresponds to the number of elements in each input ndarray. When computing the population [covariance][covariance], setting this parameter to `0` is the standard choice (i.e., the provided arrays contain data constituting entire populations). When computing the unbiased sample [covariance][covariance], setting this parameter to `1` is the standard choice (i.e., the provided arrays contain data sampled from larger populations; this is commonly referred to as Bessel's correction).

Comment on lines +145 to +146

- If provided an empty one-dimensional ndarray, the function returns `NaN`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- If provided an empty one-dimensional ndarray, the function returns `NaN`.
- Both input ndarrays should have the same number of elements.
- If provided empty one-dimensional ndarrays, the function returns `NaN`.

Comment on lines +170 to +175
// Create first one-dimensional ndarray containing pseudorandom integers drawn from a discrete uniform distribution:
var xbuf = discreteUniform( 10, -50, 50, opts );
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );

// Create second one-dimensional ndarray containing pseudorandom integers drawn from a discrete uniform distribution:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Create first one-dimensional ndarray containing pseudorandom integers drawn from a discrete uniform distribution:
var xbuf = discreteUniform( 10, -50, 50, opts );
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );
// Create second one-dimensional ndarray containing pseudorandom integers drawn from a discrete uniform distribution:
// Create one-dimensional ndarrays containing pseudorandom numbers:
var xbuf = discreteUniform( 10, -50, 50, opts );
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );

Comment on lines +3 to +5
Computes the covariance of two one-dimensional double-precision
floating-point ndarrays provided known means and using a one-pass textbook
algorithm.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Computes the covariance of two one-dimensional double-precision
floating-point ndarrays provided known means and using a one-pass textbook
algorithm.
Computes the covariance of two one-dimensional double-precision floating-
point ndarrays provided known means and using a one-pass textbook algorithm.

floating-point ndarrays provided known means and using a one-pass textbook
algorithm.

If provided an empty ndarray, the function returns `NaN`.
Copy link
Member

Choose a reason for hiding this comment

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

Should update to match README notes.

- a zero-dimensional ndarray specifying degrees of freedom
adjustment. Setting this parameter to a value other than `0` has the
effect of adjusting the divisor during the calculation of the
covariance according to `N-c` where `c` corresponds to the provided
Copy link
Member

Choose a reason for hiding this comment

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

Should be updated to match README suggestion.

Comment on lines +27 to +30
- a zero-dimensional ndarray specifying mean of the first
one-dimensional ndarray.
- a zero-dimensional ndarray specifying mean of the second
one-dimensional ndarray.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- a zero-dimensional ndarray specifying mean of the first
one-dimensional ndarray.
- a zero-dimensional ndarray specifying mean of the second
one-dimensional ndarray.
- a zero-dimensional ndarray specifying the mean of the first one-
dimensional ndarray.
- a zero-dimensional ndarray specifying the mean of the second one-
dimensional ndarray.

*
* - first one-dimensional input ndarray.
* - second one-dimensional input ndarray.
* - a zero-dimensional ndarray specifying degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the covariance according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the population covariance, setting this parameter to `0` is the standard choice (i.e., the provided arrays contain data constituting entire populations). When computing the unbiased sample covariance, setting this parameter to `1` is the standard choice (i.e., the provided arrays contain data sampled from larger populations; this is commonly referred to as Bessel's correction).
Copy link
Member

Choose a reason for hiding this comment

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

Should update to match README suggestion.

Comment on lines +35 to +36
* - a zero-dimensional ndarray specifying mean of the first one-dimensional ndarray.
* - a zero-dimensional ndarray specifying mean of the second one-dimensional ndarray.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* - a zero-dimensional ndarray specifying mean of the first one-dimensional ndarray.
* - a zero-dimensional ndarray specifying mean of the second one-dimensional ndarray.
* - a zero-dimensional ndarray specifying the mean of the first one-dimensional ndarray.
* - a zero-dimensional ndarray specifying the mean of the second one-dimensional ndarray.

'dtype': 'float64'
};

// Create first one-dimensional ndarray containing pseudorandom integers drawn from a discrete uniform distribution:
Copy link
Member

Choose a reason for hiding this comment

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

Same changes as README.

*
* - first one-dimensional input ndarray.
* - second one-dimensional input ndarray.
* - a zero-dimensional ndarray specifying degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the covariance according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the population covariance, setting this parameter to `0` is the standard choice (i.e., the provided arrays contain data constituting entire populations). When computing the unbiased sample covariance, setting this parameter to `1` is the standard choice (i.e., the provided arrays contain data sampled from larger populations; this is commonly referred to as Bessel's correction).
Copy link
Member

Choose a reason for hiding this comment

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

Should update to match README suggestion.

Comment on lines +43 to +44
* - a zero-dimensional ndarray specifying mean of the first one-dimensional ndarray.
* - a zero-dimensional ndarray specifying mean of the second one-dimensional ndarray.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* - a zero-dimensional ndarray specifying mean of the first one-dimensional ndarray.
* - a zero-dimensional ndarray specifying mean of the second one-dimensional ndarray.
* - a zero-dimensional ndarray specifying the mean of the first one-dimensional ndarray.
* - a zero-dimensional ndarray specifying the mean of the second one-dimensional ndarray.

{
"name": "@stdlib/stats/base/ndarray/dcovarmtk",
"version": "0.0.0",
"description": "Computes the covariance of two one-dimensional double-precision floating-point ndarrays provided known means and using a one-pass textbook algorithm.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Computes the covariance of two one-dimensional double-precision floating-point ndarrays provided known means and using a one-pass textbook algorithm.",
"description": "Compute the covariance of two one-dimensional double-precision floating-point ndarrays provided known means and using a one-pass textbook algorithm.",

Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

Left a few nits. Once addressed, should be ready.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Issue or pull request for adding a new feature. GSoC Google Summer of Code. gsoc: 2025 Google Summer of Code (2025). 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