Skip to content

Commit 532cd83

Browse files
committed
refactor: refactored lib folder's file to ensure consistent structure
--- 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: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent b74cfc5 commit 532cd83

File tree

7 files changed

+47
-79
lines changed

7 files changed

+47
-79
lines changed

lib/node_modules/@stdlib/stats/base/nanmeanpn/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The function has the following parameters:
6969
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
7070
- **strideX**: stride length for `x`.
7171

72-
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
72+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
7373

7474
```javascript
7575
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN ];
@@ -107,7 +107,7 @@ The function has the following additional parameters:
107107

108108
- **offsetX**: starting index for `x`.
109109

110-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on a starting indices. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value
110+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value
111111

112112
```javascript
113113
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ];
@@ -125,9 +125,9 @@ var v = nanmeanpn.ndarray( 5, x, 2, 1 );
125125
## Notes
126126

127127
- If `N <= 0`, both functions return `NaN`.
128-
- If every indexed element is `NaN`, both functions return `NaN`.
129128
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]).
130-
- Depending on the environment, the typed versions ([`dnanmeanpn`][@stdlib/stats/base/dnanmeanpn], [`snanmeanpn`][@stdlib/stats/base/snanmeanpn], etc.) are likely to be significantly more performant.
129+
- If every indexed element is `NaN`, both functions return `NaN`.
130+
- Depending on the environment, the typed versions ([`dnanmeanpn`][@stdlib/stats/strided/dnanmeanpn], [`snanmeanpn`][@stdlib/stats/strided/snanmeanpn], etc.) are likely to be significantly more performant.
131131

132132
</section>
133133

@@ -184,10 +184,10 @@ console.log( v );
184184

185185
## See Also
186186

187-
- <span class="package-name">[`@stdlib/stats/base/dnanmeanpn`][@stdlib/stats/base/dnanmeanpn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array, ignoring NaN values and using a two-pass error correction algorithm.</span>
187+
- <span class="package-name">[`@stdlib/stats/strided/dnanmeanpn`][@stdlib/stats/strided/dnanmeanpn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array, ignoring NaN values and using a two-pass error correction algorithm.</span>
188188
- <span class="package-name">[`@stdlib/stats/base/meanpn`][@stdlib/stats/base/meanpn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using a two-pass error correction algorithm.</span>
189189
- <span class="package-name">[`@stdlib/stats/base/nanmean`][@stdlib/stats/base/nanmean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array, ignoring NaN values.</span>
190-
- <span class="package-name">[`@stdlib/stats/base/snanmeanpn`][@stdlib/stats/base/snanmeanpn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array, ignoring NaN values and using a two-pass error correction algorithm.</span>
190+
- <span class="package-name">[`@stdlib/stats/strided/snanmeanpn`][@stdlib/stats/strided/snanmeanpn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array, ignoring NaN values and using a two-pass error correction algorithm.</span>
191191

192192
</section>
193193

@@ -209,13 +209,13 @@ console.log( v );
209209

210210
<!-- <related-links> -->
211211

212-
[@stdlib/stats/base/dnanmeanpn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dnanmeanpn
212+
[@stdlib/stats/strided/dnanmeanpn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dnanmeanpn
213213

214214
[@stdlib/stats/base/meanpn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/meanpn
215215

216216
[@stdlib/stats/base/nanmean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanmean
217217

218-
[@stdlib/stats/base/snanmeanpn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/snanmeanpn
218+
[@stdlib/stats/strided/snanmeanpn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/snanmeanpn
219219

220220
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
221221

lib/node_modules/@stdlib/stats/base/nanmeanpn/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var filledarrayBy = require( '@stdlib/array/filled-by' );
2727
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2828
var pow = require( '@stdlib/math/base/special/pow' );
2929
var pkg = require( './../package.json' ).name;
30-
var nanmeanpn = require( './../lib/nanmeanpn.js' );
30+
var nanmeanpn = require( './../lib/main.js' );
3131

3232

3333
// FUNCTIONS //

lib/node_modules/@stdlib/stats/base/nanmeanpn/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Computes the arithmetic mean of a strided array, ignoring `NaN` values and
44
using a two-pass error correction algorithm.
55

6-
The `N` and stride parameters determine which elements in the strided arrays
6+
The `N` and stride parameters determine which elements in the strided array
77
are accessed at runtime.
88

99
Indexing is relative to the first index. To introduce an offset, use a typed

lib/node_modules/@stdlib/stats/base/nanmeanpn/lib/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,29 @@
2727
* var nanmeanpn = require( '@stdlib/stats/base/nanmeanpn' );
2828
*
2929
* var x = [ 1.0, -2.0, NaN, 2.0 ];
30-
* var N = x.length;
3130
*
32-
* var v = nanmeanpn( N, x, 1 );
31+
* var v = nanmeanpn( 4, x, 1 );
3332
* // returns ~0.3333
3433
*
3534
* @example
36-
* var floor = require( '@stdlib/math/base/special/floor' );
3735
* var nanmeanpn = require( '@stdlib/stats/base/nanmeanpn' );
3836
*
3937
* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ];
40-
* var N = floor( x.length / 2 );
4138
*
42-
* var v = nanmeanpn.ndarray( N, x, 2, 1 );
39+
* var v = nanmeanpn.ndarray( 4, x, 2, 1 );
4340
* // returns 1.25
4441
*/
4542

4643
// MODULES //
4744

45+
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
4846
var main = require( './main.js' );
47+
var ndarray = require( './ndarray.js' );
48+
49+
50+
// MAIN //
51+
52+
setReadOnly( main, 'ndarray', ndarray );
4953

5054

5155
// EXPORTS //

lib/node_modules/@stdlib/stats/base/nanmeanpn/lib/main.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,38 @@
2020

2121
// MODULES //
2222

23-
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
24-
var nanmeanpn = require( './nanmeanpn.js' );
23+
var stride2offset = require( '@stdlib/strided/base/stride2offset' );
2524
var ndarray = require( './ndarray.js' );
2625

2726

2827
// MAIN //
2928

30-
setReadOnly( nanmeanpn, 'ndarray', ndarray );
29+
/**
30+
* Computes the arithmetic mean of a strided array, ignoring `NaN` values and using a two-pass error correction algorithm.
31+
*
32+
* ## Method
33+
*
34+
* - This implementation uses a two-pass approach, as suggested by Neely (1966).
35+
*
36+
* ## References
37+
*
38+
* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958).
39+
* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036).
40+
*
41+
* @param {PositiveInteger} N - number of indexed elements
42+
* @param {NumericArray} x - input array
43+
* @param {integer} strideX - stride length
44+
* @returns {number} arithmetic mean
45+
*
46+
* @example
47+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
48+
*
49+
* var v = nanmeanpn( 4, x, 1 );
50+
* // returns ~0.3333
51+
*/
52+
function nanmeanpn( N, x, strideX ) {
53+
return ndarray( N, x, strideX, stride2offset( N, strideX ) );
54+
}
3155

3256

3357
// EXPORTS //

lib/node_modules/@stdlib/stats/base/nanmeanpn/lib/nanmeanpn.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

lib/node_modules/@stdlib/stats/base/nanmeanpn/test/test.nanmeanpn.js renamed to lib/node_modules/@stdlib/stats/base/nanmeanpn/test/test.main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var tape = require( 'tape' );
2424
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var Float64Array = require( '@stdlib/array/float64' );
27-
var nanmeanpn = require( './../lib/nanmeanpn.js' );
27+
var nanmeanpn = require( './../lib/main.js' );
2828

2929

3030
// TESTS //

0 commit comments

Comments
 (0)