Skip to content

Commit a26e913

Browse files
committed
fix: made suggested changes
--- 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: 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent fd45646 commit a26e913

File tree

10 files changed

+144
-70
lines changed

10 files changed

+144
-70
lines changed

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

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ var meanpn = require( '@stdlib/stats/base/meanpn' );
5353

5454
#### meanpn( N, x, strideX )
5555

56-
Computes the [arithmetic mean][arithmetic-mean] of a strided array `x` using a two-pass error correction algorithm.
56+
Computes the [arithmetic mean][arithmetic-mean] of a strided array using a two-pass error correction algorithm.
5757

5858
```javascript
5959
var x = [ 1.0, -2.0, 2.0 ];
60-
var N = x.length;
6160

62-
var v = meanpn( N, x, 1 );
61+
var v = meanpn( x.length, x, 1 );
6362
// returns ~0.3333
6463
```
6564

@@ -69,15 +68,11 @@ The function has the following parameters:
6968
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
7069
- **strideX**: stride length for `x`.
7170

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 the input array,
71+
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 the input array
7372

7473
```javascript
75-
var floor = require( '@stdlib/math/base/special/floor' );
76-
7774
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];
78-
var N = floor( x.length / 2 );
79-
80-
var v = meanpn( N, x, 2 );
75+
var v = meanpn( 4, x, 2 );
8176
// returns 1.25
8277
```
8378

@@ -87,14 +82,11 @@ Note that indexing is relative to the first index. To introduce an offset, use [
8782

8883
```javascript
8984
var Float64Array = require( '@stdlib/array/float64' );
90-
var floor = require( '@stdlib/math/base/special/floor' );
9185

9286
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
9387
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
9488

95-
var N = floor( x0.length / 2 );
96-
97-
var v = meanpn( N, x1, 2 );
89+
var v = meanpn( 4, x1, 2 );
9890
// returns 1.25
9991
```
10092

@@ -104,25 +96,21 @@ Computes the [arithmetic mean][arithmetic-mean] of a strided array using a two-p
10496

10597
```javascript
10698
var x = [ 1.0, -2.0, 2.0 ];
107-
var N = x.length;
10899

109-
var v = meanpn.ndarray( N, x, 1, 0 );
100+
var v = meanpn.ndarray( x.length, x, 1, 0 );
110101
// returns ~0.33333
111102
```
112103

113104
The function has the following additional parameters:
114105

115106
- **offsetX**: starting index for `x`.
116107

117-
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
108+
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 the strided array starting from the second element
118109

119110
```javascript
120-
var floor = require( '@stdlib/math/base/special/floor' );
121-
122111
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
123-
var N = floor( x.length / 2 );
124112

125-
var v = meanpn.ndarray( N, x, 2, 1 );
113+
var v = meanpn.ndarray( 4, x, 2, 1 );
126114
// returns 1.25
127115
```
128116

@@ -135,6 +123,7 @@ var v = meanpn.ndarray( N, x, 2, 1 );
135123
## Notes
136124

137125
- If `N <= 0`, both functions return `NaN`.
126+
- 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]).
138127
- Depending on the environment, the typed versions ([`dmeanpn`][@stdlib/stats/base/dmeanpn], [`smeanpn`][@stdlib/stats/base/smeanpn], etc.) are likely to be significantly more performant.
139128

140129
</section>
@@ -210,6 +199,8 @@ console.log( v );
210199

211200
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
212201

202+
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
203+
213204
[@neely:1966a]: https://doi.org/10.1145/365719.365958
214205

215206
[@schubert:2018a]: https://doi.org/10.1145/3221269.3223036

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,18 @@
3232
// Standard Usage:
3333
> var x = [ 1.0, -2.0, 2.0 ];
3434
> {{alias}}( x.length, x, 1 )
35-
~0.3333
35+
0.3333333333333333
3636

3737
// Using `N` and `stride` parameters:
3838
> x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ];
39-
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
40-
> var stride = 2;
41-
> {{alias}}( N, x, stride )
42-
~0.3333
39+
> {{alias}}( 3, x, 2 )
40+
0.3333333333333333
4341

4442
// Using view offsets:
4543
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
4644
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
47-
> N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
48-
> stride = 2;
49-
> {{alias}}( N, x1, stride )
50-
~-0.3333
45+
> {{alias}}( 6, x1, 2 )
46+
NaN
5147

5248

5349
{{alias}}.ndarray( N, x, strideX, offsetX )
@@ -86,8 +82,7 @@
8682

8783
// Using offset parameter:
8884
> var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ];
89-
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
90-
> {{alias}}.ndarray( N, x, 2, 1 )
85+
> {{alias}}.ndarray( 3, x, 2, 1 )
9186
~-0.3333
9287

9388
See Also

lib/node_modules/@stdlib/stats/base/meanpn/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2025 The Stdlib Authors.
4+
* Copyright (c) 2020 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/stats/base/meanpn/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2222
var meanpn = require( './../lib' );
2323

24-
var x = discreteUniform( 10, 0, 100, {
24+
var x = discreteUniform( 10, -50, 50, {
2525
'dtype': 'float64'
2626
});
2727
console.log( x );

lib/node_modules/@stdlib/stats/base/meanpn/lib/accessors.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,20 @@ var gapxsumpw = require( '@stdlib/blas/ext/base/gapxsumpw' ).ndarray;
2828

2929
/**
3030
* Computes the arithmetic mean of a strided array using a two-pass error correction algorithm.
31-
*
31+
* @private
3232
* @param {PositiveInteger} N - number of indexed elements
33-
* @param {NumericArray} x - input array
33+
* @param {NumericArray} x - input array object
3434
* @param {integer} strideX - stride length
3535
* @param {NonNegativeInteger} offsetX - starting index
3636
* @returns {number} arithmetic mean
3737
*
3838
* @example
39-
* var floor = require( '@stdlib/math/base/special/floor' );
4039
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
4140
* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
4241
*
43-
* var x = toAccessorArray([ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]);
44-
* var N = floor( x.length / 2 );
42+
* var x = toAccessorArray( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
4543
*
46-
* var v = meanpn( N, arraylike2object(x), 2, 1 );
44+
* var v = meanpn( 4, arraylike2object( x ), 2, 1 );
4745
* // returns 1.25
4846
*/
4947
function meanpn( N, x, strideX, offsetX ) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@
3333
* // returns ~0.3333
3434
*
3535
* @example
36-
* var floor = require( '@stdlib/math/base/special/floor' );
3736
* var meanpn = require( '@stdlib/stats/base/meanpn' );
3837
*
3938
* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
40-
* var N = floor( x.length / 2 );
4139
*
42-
* var v = meanpn.ndarray( N, x, 2, 1 );
40+
* var v = meanpn.ndarray( 4, x, 2, 1 );
4341
* // returns 1.25
4442
*/
4543

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2025 The Stdlib Authors.
4+
* Copyright (c) 2020 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/stats/base/meanpn/lib/ndarray.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ var accessors = require( './accessors.js' );
4747
* @returns {number} arithmetic mean
4848
*
4949
* @example
50-
* var floor = require( '@stdlib/math/base/special/floor' );
5150
*
5251
* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
53-
* var N = floor( x.length / 2 );
5452
*
55-
* var v = meanpn( N, x, 2, 1 );
53+
* var v = meanpn( 4, x, 2, 1 );
5654
* // returns 1.25
5755
*/
5856
function meanpn( N, x, strideX, offsetX ) {

lib/node_modules/@stdlib/stats/base/meanpn/test/test.meanpn.js

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var floor = require( '@stdlib/math/base/special/floor' );
2524
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2625
var Float64Array = require( '@stdlib/array/float64' );
2726
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
@@ -47,12 +46,12 @@ tape( 'the function calculates the arithmetic mean of a strided array (accessors
4746

4847
x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ];
4948

50-
v = meanpn( x.length, toAccessorArray(x), 1 );
49+
v = meanpn( x.length, toAccessorArray( x ), 1 );
5150
t.strictEqual( v, 0.5, 'returns expected value' );
5251

5352
x = [ -4.0 ];
5453

55-
v = meanpn( x.length, toAccessorArray(x), 1 );
54+
v = meanpn( x.length, toAccessorArray( x ), 1 );
5655
t.strictEqual( v, -4.0, 'returns expected value' );
5756

5857
t.end();
@@ -103,7 +102,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
103102
});
104103

105104
tape( 'the function supports a `stride` parameter', function test( t ) {
106-
var N;
107105
var x;
108106
var v;
109107

@@ -118,15 +116,34 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
118116
2.0
119117
];
120118

121-
N = floor( x.length / 2 );
122-
v = meanpn( N, x, 2 );
119+
v = meanpn( 4, x, 2 );
120+
121+
t.strictEqual( v, 1.25, 'returns expected value' );
122+
t.end();
123+
});
124+
125+
tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
126+
var x;
127+
var v;
128+
129+
x = [
130+
1.0, // 0
131+
2.0,
132+
2.0, // 1
133+
-7.0,
134+
-2.0, // 2
135+
3.0,
136+
4.0, // 3
137+
2.0
138+
];
139+
140+
v = meanpn( 4, toAccessorArray( x ), 2 );
123141

124142
t.strictEqual( v, 1.25, 'returns expected value' );
125143
t.end();
126144
});
127145

128146
tape( 'the function supports a negative `stride` parameter', function test( t ) {
129-
var N;
130147
var x;
131148
var v;
132149

@@ -141,8 +158,28 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
141158
2.0
142159
];
143160

144-
N = floor( x.length / 2 );
145-
v = meanpn( N, x, -2 );
161+
v = meanpn( 4, x, -2 );
162+
163+
t.strictEqual( v, 1.25, 'returns expected value' );
164+
t.end();
165+
});
166+
167+
tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
168+
var x;
169+
var v;
170+
171+
x = [
172+
1.0, // 3
173+
2.0,
174+
2.0, // 2
175+
-7.0,
176+
-2.0, // 1
177+
3.0,
178+
4.0, // 0
179+
2.0
180+
];
181+
182+
v = meanpn( 4, toAccessorArray( x ), -2 );
146183

147184
t.strictEqual( v, 1.25, 'returns expected value' );
148185
t.end();
@@ -160,10 +197,21 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
160197
t.end();
161198
});
162199

200+
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element (accessors)', function test( t ) {
201+
var x;
202+
var v;
203+
204+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
205+
206+
v = meanpn( x.length, toAccessorArray( x ), 0 );
207+
t.strictEqual( v, 1.0, 'returns expected value' );
208+
209+
t.end();
210+
});
211+
163212
tape( 'the function supports view offsets', function test( t ) {
164213
var x0;
165214
var x1;
166-
var N;
167215
var v;
168216

169217
x0 = new Float64Array([
@@ -179,9 +227,8 @@ tape( 'the function supports view offsets', function test( t ) {
179227
]);
180228

181229
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
182-
N = floor(x1.length / 2);
183230

184-
v = meanpn( N, x1, 2 );
231+
v = meanpn( 4, x1, 2 );
185232
t.strictEqual( v, 1.25, 'returns expected value' );
186233

187234
t.end();

0 commit comments

Comments
 (0)