Skip to content

Commit 17f5063

Browse files
committed
feat: add support for accessor arrays and refactor stats/base/stdevyc
1 parent 0cac3f8 commit 17f5063

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ var varianceyc = require( '@stdlib/stats/base/varianceyc' ).ndarray;
4848
* var v = stdevyc( x.length, 1, x, 1, 0 );
4949
* // returns ~2.0817
5050
*/
51-
function stdevyc( N, correction, x, strideX, offsetX ) {
52-
var o;
51+
function stdevyc( N, correction, x, strideX ) {
52+
var o;
5353

54-
if ( N <= 0 ) {
55-
return NaN;
56-
}
57-
o = arraylike2object( x );
58-
if ( o.accessorProtocol ) {
59-
return accessors( N, correction, o, strideX, offsetX );
60-
}
61-
return sqrt( varianceyc( N, correction, x, strideX, offsetX ) );
54+
if ( N <= 0 ) {
55+
return NaN;
56+
}
57+
o = arraylike2object( x );
58+
if ( o.accessorProtocol ) {
59+
return accessors( N, correction, o, strideX, 0 );
60+
}
61+
return sqrt( varianceyc( N, correction, x, strideX ) );
6262
}
6363

6464

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

Lines changed: 3 additions & 10 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 sqrt = require( '@stdlib/math/base/special/sqrt' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var Float64Array = require( '@stdlib/array/float64' );
@@ -122,7 +121,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
122121
});
123122

124123
tape( 'the function supports a `stride` parameter', function test( t ) {
125-
var N;
126124
var x;
127125
var v;
128126

@@ -137,15 +135,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
137135
2.0
138136
];
139137

140-
N = floor( x.length / 2 );
141-
v = stdevyc( N, 1, x, 2 );
138+
v = stdevyc( 4, 1, x, 2 );
142139

143140
t.strictEqual( v, 2.5, 'returns expected value' );
144141
t.end();
145142
});
146143

147144
tape( 'the function supports a negative `stride` parameter', function test( t ) {
148-
var N;
149145
var x;
150146
var v;
151147

@@ -160,8 +156,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
160156
2.0
161157
];
162158

163-
N = floor( x.length / 2 );
164-
v = stdevyc( N, 1, x, -2 );
159+
v = stdevyc( 4, 1, x, -2 );
165160

166161
t.strictEqual( v, 2.5, 'returns expected value' );
167162
t.end();
@@ -182,7 +177,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
182177
tape( 'the function supports view offsets', function test( t ) {
183178
var x0;
184179
var x1;
185-
var N;
186180
var v;
187181

188182
x0 = new Float64Array([
@@ -198,9 +192,8 @@ tape( 'the function supports view offsets', function test( t ) {
198192
]);
199193

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

203-
v = stdevyc( N, 1, x1, 2 );
196+
v = stdevyc( 4, 1, x1, 2 );
204197
t.strictEqual( v, 2.5, 'returns expected value' );
205198

206199
t.end();

0 commit comments

Comments
 (0)