-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add stats/base/ndarray/stdev
#9248
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
base: develop
Are you sure you want to change the base?
feat: add stats/base/ndarray/stdev
#9248
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
| Parameters | ||
| ---------- | ||
| arrays: ArrayLikeObject<ndarray> | ||
| Array-like object containing two elements: a one-dimensional input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated to match the README.
lib/node_modules/@stdlib/stats/base/ndarray/stdev/docs/repl.txt
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/stats/base/ndarray/stdev/docs/repl.txt
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
| /** | ||
| * Computes the standard deviation of a one-dimensional ndarray. | ||
| * | ||
| * @param arrays - array-like object containing an input ndarray and a correction ndarray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param arrays - array-like object containing an input ndarray and a correction ndarray | |
| * @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray specifying a degrees of freedom adjustment |
|
|
||
| /// <reference types="@stdlib/types"/> | ||
|
|
||
| import { ndarray } from '@stdlib/types/ndarray'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import { ndarray } from '@stdlib/types/ndarray'; | |
| import { typedndarray } from '@stdlib/types/ndarray'; |
| * var v = stdev( [ x, correction ] ); | ||
| * // returns ~2.0817 | ||
| */ | ||
| declare function stdev<T extends ndarray = ndarray>( arrays: [ T, ndarray ] ): number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| declare function stdev<T extends ndarray = ndarray>( arrays: [ T, ndarray ] ): number; | |
| declare function stdev<T extends typedndarray = typedndarray>( arrays: [ T, T ] ): number; |
|
|
||
| var correction = scalar2ndarray( 1.0, opts ); | ||
|
|
||
| console.log( ndarray2array( x ) ); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var correction = scalar2ndarray( 1.0, opts ); | |
| console.log( ndarray2array( x ) ); | |
| console.log( ndarray2array( x ) ); | |
| var correction = scalar2ndarray( 1.0, opts ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match README.
| * var stdev = require( '@stdlib/stats/base/ndarray/stdev' ); | ||
| * | ||
| * var opts = { | ||
| * 'dtype': 'float64' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * 'dtype': 'float64' | |
| * 'dtype': 'generic' |
| /** | ||
| * Computes the standard deviation of a one-dimensional ndarray. | ||
| * | ||
| * @param {ArrayLikeObject<Object>} arrays - array-like object containing ndarrays |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param {ArrayLikeObject<Object>} arrays - array-like object containing ndarrays | |
| * @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray specifying a degrees of freedom adjustment |
| var x; | ||
| var N; | ||
|
|
||
| x = arrays[ 0 ]; | ||
| correction = ndarraylike2scalar( arrays[ 1 ] ); | ||
|
|
||
| N = numelDimension( x, 0 ); | ||
| stride = getStride( x, 0 ); | ||
| return strided( N, correction, getData( x ), stride, getOffset( x ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var x; | |
| var N; | |
| x = arrays[ 0 ]; | |
| correction = ndarraylike2scalar( arrays[ 1 ] ); | |
| N = numelDimension( x, 0 ); | |
| stride = getStride( x, 0 ); | |
| return strided( N, correction, getData( x ), stride, getOffset( x ) ); | |
| 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 |
Consistency with elsewhere.
| { | ||
| "name": "@stdlib/stats/base/ndarray/stdev", | ||
| "version": "0.0.0", | ||
| "description": "Compute the standard deviation of one-dimensional ndarrays.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "description": "Compute the standard deviation of one-dimensional ndarrays.", | |
| "description": "Compute the standard deviation of a one-dimensional ndarray.", |
| "stats", | ||
| "mathematics", | ||
| "math", | ||
| "standard deviation", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest sticking closer to the list of keywords in https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/%40stdlib/stats/strided/stdev/package.json#L58.
kgryte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left initial comments.
Co-authored-by: Athan <kgryte@gmail.com> Signed-off-by: Pratik <bhagwatpratik781@gmail.com>
Resolves none
Description
This pull request:
feat: add
stats/base/ndarray/stdevRelated Issues
This pull request has the following related issues:
none
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
{{TODO: add disclosure if applicable}}
@stdlib-js/reviewers