Skip to content

Commit 39f3cc6

Browse files
committed
Auto-generated commit
1 parent abd4e19 commit 39f3cc6

File tree

18 files changed

+725
-145
lines changed

18 files changed

+725
-145
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,37 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-05-19)
7+
## Unreleased (2025-07-09)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`719cc56`](https://github.com/stdlib-js/stdlib/commit/719cc56a839fc0e790c51a21621c8d71d27af5f8) - add support for accessor arrays and refactor `stats/base/nanstdevwd` [(#7590)](https://github.com/stdlib-js/stdlib/pull/7590)
14+
15+
</section>
16+
17+
<!-- /.features -->
18+
19+
<section class="issues">
20+
21+
### Closed Issues
22+
23+
This release closes the following issue:
24+
25+
[#5671](https://github.com/stdlib-js/stdlib/issues/5671)
26+
27+
</section>
28+
29+
<!-- /.issues -->
830

931
<section class="commits">
1032

1133
### Commits
1234

1335
<details>
1436

37+
- [`719cc56`](https://github.com/stdlib-js/stdlib/commit/719cc56a839fc0e790c51a21621c8d71d27af5f8) - **feat:** add support for accessor arrays and refactor `stats/base/nanstdevwd` [(#7590)](https://github.com/stdlib-js/stdlib/pull/7590) _(by Gururaj Gurram)_
1538
- [`e6caafc`](https://github.com/stdlib-js/stdlib/commit/e6caafc261076eba2325f589f094c8264ba6d8b2) - **refactor:** update paths _(by Aayush Khanna)_
1639

1740
</details>
@@ -24,9 +47,10 @@
2447

2548
### Contributors
2649

27-
A total of 1 person contributed to this release. Thank you to this contributor:
50+
A total of 2 people contributed to this release. Thank you to the following contributors:
2851

2952
- Aayush Khanna
53+
- Gururaj Gurram
3054

3155
</section>
3256

CONTRIBUTORS

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ Ali Salesi <[email protected]>
2121
AlyAbdelmoneim <[email protected]>
2222
Aman Bhansali <[email protected]>
2323
AmanBhadkariya <[email protected]>
24+
Amisha Chhajed <[email protected]>
2425
Amit Jimiwal <[email protected]>
26+
Annamalai Prabu <[email protected]>
2527
Anshu Kumar <[email protected]>
2628
Anshu Kumar <[email protected]>
2729
Anudeep Sanapala <[email protected]>
30+
Arihant Pal <[email protected]>
31+
Aryan Bhirud <[email protected]>
2832
Athan Reines <[email protected]>
2933
3034
Bhavishy Agrawal <[email protected]>
@@ -34,10 +38,12 @@ Bryan Elee <[email protected]>
3438
Chinmay Joshi <[email protected]>
3539
Christopher Dambamuromo <[email protected]>
3640
41+
Daniel Hernandez Gomez <[email protected]>
3742
Daniel Killenberger <[email protected]>
3843
Daniel Yu <[email protected]>
3944
Debashis Maharana <[email protected]>
4045
Deep Trivedi <[email protected]>
46+
Deepak Singh <[email protected]>
4147
Desh Deepak Kant <[email protected]>
4248
4349
Dhanyabad behera <[email protected]>
@@ -53,11 +59,13 @@ Frank Kovacs <[email protected]>
5359
GK Bishnoi <[email protected]>
5460
GURU PRASAD SHARMA <[email protected]>
5561
62+
Gautam Kaushik <[email protected]>
5663
Gautam sharma <[email protected]>
5764
Girish Garg <[email protected]>
5865
Golden Kumar <[email protected]>
5966
Gunj Joshi <[email protected]>
6067
Gururaj Gurram <[email protected]>
68+
Harishchandra Reddy <[email protected]>
6169
Haroon Rasheed <[email protected]>
6270
6371
@@ -80,6 +88,7 @@ Joris Labie <[email protected]>
8088
Justin Dennison <[email protected]>
8189
Justyn Shelby <[email protected]>
8290
Karan Anand <[email protected]>
91+
Karan Vasudevamurthy <[email protected]>
8392
Karan Yadav <[email protected]>
8493
Karthik Prakash <[email protected]>
8594
Kaushikgtm <[email protected]>
@@ -89,6 +98,7 @@ Krishnam Agarwal <[email protected]>
8998
Krishnendu Das <[email protected]>
9099
Kshitij-Dale <[email protected]>
91100
Lalit Narayan Yadav <[email protected]>
101+
Lokesh Ranjan <[email protected]>
92102
Lovelin Dhoni J B <[email protected]>
93103
94104
Mahfuza Humayra Mohona <[email protected]>
@@ -117,6 +127,7 @@ Ognjen Jevremović <[email protected]>
117127
Oneday12323 <[email protected]>
118128
Ori Miles <[email protected]>
119129
Philipp Burckhardt <[email protected]>
130+
Pierre Forstmann <[email protected]>
120131
Prajjwal Bajpai <[email protected]>
121132
Prajwal Kulkarni <[email protected]>
122133
Pranav Goswami <[email protected]>
@@ -146,6 +157,7 @@ Ryan Seal <[email protected]>
146157
Rylan Yang <[email protected]>
147158
SAHIL KUMAR <[email protected]>
148159
SHIVAM YADAV <[email protected]>
160+
Sachin Raj <[email protected]>
149161
Sahil Goyal <[email protected]>
150162
Sai Avinash <[email protected]>
151163
Sai Srikar Dumpeti <[email protected]>
@@ -166,10 +178,14 @@ Spandan Barve <[email protected]>
166178
Stephannie Jiménez Gacha <[email protected]>
167179
Suhaib Ilahi <[email protected]>
168180
Suraj Kumar <[email protected]>
181+
Swapnil Hajare <[email protected]>
169182
Tanishq Ahuja <[email protected]>
170183
Tirtadwipa Manunggal <[email protected]>
171184
Tudor Pagu <[email protected]>
172185
Tufailahmed Bargir <[email protected]>
186+
Tushar Bhardwaj <[email protected]>
187+
Uday Kakade <[email protected]>
188+
Ujjwal Kirti <[email protected]>
173189
Utkarsh <http://[email protected]>
174190
Utkarsh Raj <[email protected]>
175191
UtkershBasnet <[email protected]>
@@ -183,11 +199,13 @@ Yaswanth Kosuru <[email protected]>
183199
Yernar Yergaziyev <[email protected]>
184200
Yugal Kaushik <[email protected]>
185201
Yuvi Mittal <[email protected]>
202+
deepak427 <[email protected]>
186203
devshree-bhati <[email protected]>
187204
188205
ekambains <[email protected]>
189206
fadiothman22 <[email protected]>
190207
iraandrushko <[email protected]>
208+
191209
lohithganni <[email protected]>
192210
olenkabilonizhka <[email protected]>
193211
pranav-1720 <[email protected]>

README.md

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ To view installation and usage instructions specific to each branch build, be su
131131
var nanstdevwd = require( '@stdlib/stats-base-nanstdevwd' );
132132
```
133133

134-
#### nanstdevwd( N, correction, x, stride )
134+
#### nanstdevwd( N, correction, x, strideX )
135135

136-
Computes the [standard deviation][standard-deviation] of a strided array `x` ignoring `NaN` values and using Welford's algorithm.
136+
Computes the [standard deviation][standard-deviation] of a strided array ignoring `NaN` values and using Welford's algorithm.
137137

138138
```javascript
139139
var x = [ 1.0, -2.0, NaN, 2.0 ];
@@ -147,38 +147,32 @@ The function has the following parameters:
147147
- **N**: number of indexed elements.
148148
- **correction**: 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 [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
149149
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
150-
- **stride**: index increment for `x`.
150+
- **strideX**: stride length for `x`.
151151

152152
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`,
153153

154154
```javascript
155-
var floor = require( '@stdlib/math-base-special-floor' );
156-
157155
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ];
158-
var N = floor( x.length / 2 );
159156

160-
var v = nanstdevwd( N, 1, x, 2 );
157+
var v = nanstdevwd( 5, 1, x, 2 );
161158
// returns 2.5
162159
```
163160

164161
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
165162

166-
<!-- eslint-disable stdlib/capitalized-comments -->
163+
<!-- eslint-disable stdlib/capitalized-comments, max-len -->
167164

168165
```javascript
169166
var Float64Array = require( '@stdlib/array-float64' );
170-
var floor = require( '@stdlib/math-base-special-floor' );
171167

172-
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
168+
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
173169
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
174170

175-
var N = floor( x0.length / 2 );
176-
177-
var v = nanstdevwd( N, 1, x1, 2 );
171+
var v = nanstdevwd( 5, 1, x1, 2 );
178172
// returns 2.5
179173
```
180174

181-
#### nanstdevwd.ndarray( N, correction, x, stride, offset )
175+
#### nanstdevwd.ndarray( N, correction, x, strideX, offsetX )
182176

183177
Computes the [standard deviation][standard-deviation] of a strided array ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics.
184178

@@ -191,17 +185,14 @@ var v = nanstdevwd.ndarray( x.length, 1, x, 1, 0 );
191185

192186
The function has the following additional parameters:
193187

194-
- **offset**: starting index for `x`.
188+
- **offsetX**: starting index for `x`.
195189

196-
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 [standard deviation][standard-deviation] for every other value in `x` starting from the second value
190+
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 [standard deviation][standard-deviation] for every other element in `x` starting from the second element
197191

198192
```javascript
199-
var floor = require( '@stdlib/math-base-special-floor' );
193+
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ];
200194

201-
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
202-
var N = floor( x.length / 2 );
203-
204-
var v = nanstdevwd.ndarray( N, 1, x, 2, 1 );
195+
var v = nanstdevwd.ndarray( 5, 1, x, 2, 1 );
205196
// returns 2.5
206197
```
207198

@@ -215,6 +206,7 @@ var v = nanstdevwd.ndarray( N, 1, x, 2, 1 );
215206

216207
- If `N <= 0`, both functions return `NaN`.
217208
- If `n - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements), both functions return `NaN`.
209+
- 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]).
218210
- Depending on the environment, the typed versions ([`dnanstdevwd`][@stdlib/stats/strided/dnanstdevwd], [`snanstdevwd`][@stdlib/stats/base/snanstdevwd], etc.) are likely to be significantly more performant.
219211

220212
</section>
@@ -228,18 +220,19 @@ var v = nanstdevwd.ndarray( N, 1, x, 2, 1 );
228220
<!-- eslint no-undef: "error" -->
229221

230222
```javascript
231-
var randu = require( '@stdlib/random-base-randu' );
232-
var round = require( '@stdlib/math-base-special-round' );
233-
var Float64Array = require( '@stdlib/array-float64' );
223+
var uniform = require( '@stdlib/random-base-uniform' );
224+
var filledarrayBy = require( '@stdlib/array-filled-by' );
225+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
234226
var nanstdevwd = require( '@stdlib/stats-base-nanstdevwd' );
235227

236-
var x;
237-
var i;
238-
239-
x = new Float64Array( 10 );
240-
for ( i = 0; i < x.length; i++ ) {
241-
x[ i ] = round( (randu()*100.0) - 50.0 );
228+
function rand() {
229+
if ( bernoulli( 0.8 ) < 1 ) {
230+
return NaN;
231+
}
232+
return uniform( -50.0, 50.0 );
242233
}
234+
235+
var x = filledarrayBy( 10, 'float64', rand );
243236
console.log( x );
244237

245238
var v = nanstdevwd( x.length, 1, x, 1 );
@@ -359,6 +352,8 @@ Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
359352

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

355+
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/array-base-accessor
356+
362357
[@welford:1962a]: https://doi.org/10.1080/00401706.1962.10490022
363358

364359
[@vanreeken:1968a]: https://doi.org/10.1145/362929.362961

benchmark/benchmark.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,30 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-base-uniform' );
25+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
26+
var filledarrayBy = require( '@stdlib/array-filled-by' );
2527
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2628
var pow = require( '@stdlib/math-base-special-pow' );
2729
var pkg = require( './../package.json' ).name;
28-
var nanstdevwd = require( './../lib/nanstdevwd.js' );
30+
var nanstdevwd = require( './../lib/main.js' );
2931

3032

3133
// FUNCTIONS //
3234

35+
/**
36+
* Returns a random number.
37+
*
38+
* @private
39+
* @returns {number} random number
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.8 ) < 1 ) {
43+
return NaN;
44+
}
45+
return uniform( -10.0, 10.0 );
46+
}
47+
3348
/**
3449
* Creates a benchmark function.
3550
*
@@ -38,17 +53,7 @@ var nanstdevwd = require( './../lib/nanstdevwd.js' );
3853
* @returns {Function} benchmark function
3954
*/
4055
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = [];
45-
for ( i = 0; i < len; i++ ) {
46-
if ( randu() < 0.2 ) {
47-
x.push( NaN );
48-
} else {
49-
x.push( ( randu()*20.0 ) - 10.0 );
50-
}
51-
}
56+
var x = filledarrayBy( len, 'generic', rand );
5257
return benchmark;
5358

5459
function benchmark( b ) {

benchmark/benchmark.ndarray.js

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

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-base-uniform' );
25+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
26+
var filledarrayBy = require( '@stdlib/array-filled-by' );
2527
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2628
var pow = require( '@stdlib/math-base-special-pow' );
2729
var pkg = require( './../package.json' ).name;
@@ -30,6 +32,19 @@ var nanstdevwd = require( './../lib/ndarray.js' );
3032

3133
// FUNCTIONS //
3234

35+
/**
36+
* Returns a random number.
37+
*
38+
* @private
39+
* @returns {number} random number
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.8 ) < 1 ) {
43+
return NaN;
44+
}
45+
return uniform( -10.0, 10.0 );
46+
}
47+
3348
/**
3449
* Creates a benchmark function.
3550
*
@@ -38,17 +53,7 @@ var nanstdevwd = require( './../lib/ndarray.js' );
3853
* @returns {Function} benchmark function
3954
*/
4055
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = [];
45-
for ( i = 0; i < len; i++ ) {
46-
if ( randu() < 0.2 ) {
47-
x.push( NaN );
48-
} else {
49-
x.push( ( randu()*20.0 ) - 10.0 );
50-
}
51-
}
56+
var x = filledarrayBy( len, 'generic', rand );
5257
return benchmark;
5358

5459
function benchmark( b ) {

dist/index.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)