Skip to content

Commit ddf944e

Browse files
committed
Auto-generated commit
1 parent def9b24 commit ddf944e

File tree

18 files changed

+727
-146
lines changed

18 files changed

+727
-146
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-05)
7+
## Unreleased (2025-07-09)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`5654424`](https://github.com/stdlib-js/stdlib/commit/5654424510f9b6d9273b5ce4c60f365761a53cca) - add support for accessor arrays and refactor `stats/base/nanstdevch` [(#7588)](https://github.com/stdlib-js/stdlib/pull/7588)
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+
[#5668](https://github.com/stdlib-js/stdlib/issues/5668)
26+
27+
</section>
28+
29+
<!-- /.issues -->
830

931
<section class="commits">
1032

1133
### Commits
1234

1335
<details>
1436

37+
- [`5654424`](https://github.com/stdlib-js/stdlib/commit/5654424510f9b6d9273b5ce4c60f365761a53cca) - **feat:** add support for accessor arrays and refactor `stats/base/nanstdevch` [(#7588)](https://github.com/stdlib-js/stdlib/pull/7588) _(by Gururaj Gurram)_
1538
- [`df4afcc`](https://github.com/stdlib-js/stdlib/commit/df4afcc21abb34b90a9e196f289bb5b3c50708a4) - **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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ Ali Salesi <ali_sal1381@yahoo.com>
2121
AlyAbdelmoneim <148393799+AlyAbdelmoneim@users.noreply.github.com>
2222
Aman Bhansali <bhansali.1@iitj.ac.in>
2323
AmanBhadkariya <140033975+AmanBhadkariya@users.noreply.github.com>
24+
Amisha Chhajed <136238836+amishhaa@users.noreply.github.com>
2425
Amit Jimiwal <amitjimiwal45@gmail.com>
26+
Annamalai Prabu <apfossdev@gmail.com>
2527
Anshu Kumar <132515490+anxhukumar@users.noreply.github.com>
2628
Anshu Kumar <contact.anshukumar@protonmail.com>
2729
Anudeep Sanapala <anudeep0306@gmail.com>
30+
Arihant Pal <arihant0pal@gmail.com>
31+
Aryan Bhirud <112156883+AryanBhirud@users.noreply.github.com>
2832
Athan Reines <kgryte@gmail.com>
2933
Ayaka <73595362+USERSATOSHI@users.noreply.github.com>
3034
Bhavishy Agrawal <90029607+bhavishy2801@users.noreply.github.com>
@@ -34,10 +38,12 @@ Bryan Elee <rxbryn@gmail.com>
3438
Chinmay Joshi <86140365+JawHawk@users.noreply.github.com>
3539
Christopher Dambamuromo <chridam@gmail.com>
3640
Dan Rose <danoftheroses@gmail.com>
41+
Daniel Hernandez Gomez <156333015+dhernandeez13@users.noreply.github.com>
3742
Daniel Killenberger <daniel.killenberger@gmail.com>
3843
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
3944
Debashis Maharana <debashismaharana7854@gmail.com>
4045
Deep Trivedi <128926685+thedeeppp@users.noreply.github.com>
46+
Deepak Singh <78257493+Deepak91168@users.noreply.github.com>
4147
Desh Deepak Kant <118960904+DeshDeepakKant@users.noreply.github.com>
4248
Dev Goel <135586571+corsairier@users.noreply.github.com>
4349
Dhanyabad behera <110620935+dhanyabad11@users.noreply.github.com>
@@ -53,11 +59,13 @@ Frank Kovacs <fran70kk@gmail.com>
5359
GK Bishnoi <gkishan1kyt@gmail.com>
5460
GURU PRASAD SHARMA <168292003+GURUPRASADSHARMA@users.noreply.github.com>
5561
Gaurav <gaurav70380@gmail.com>
62+
Gautam Kaushik <162317291+Kaushikgtm@users.noreply.github.com>
5663
Gautam sharma <gautamkrishnasharma1@gmail.com>
5764
Girish Garg <garggirish2020@gmail.com>
5865
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
5966
Gunj Joshi <gunjjoshi8372@gmail.com>
6067
Gururaj Gurram <gururajgurram1512@gmail.com>
68+
Harishchandra Reddy <harish.7000@gmail.com>
6169
Haroon Rasheed <51189276+haroon26@users.noreply.github.com>
6270
Harsh <harshyadav6078@gmail.com>
6371
HarshaNP <96897754+GittyHarsha@users.noreply.github.com>
@@ -80,6 +88,7 @@ Joris Labie <joris.labie1@gmail.com>
8088
Justin Dennison <justin1dennison@gmail.com>
8189
Justyn Shelby <96994781+ShelbyJustyn@users.noreply.github.com>
8290
Karan Anand <anandkarancompsci@gmail.com>
91+
Karan Vasudevamurthy <karanlvm123@gmail.com>
8392
Karan Yadav <77043443+karanBRAVO@users.noreply.github.com>
8493
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
8594
Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
@@ -89,6 +98,7 @@ Krishnam Agarwal <83017176+888krishnam@users.noreply.github.com>
8998
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
9099
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
91100
Lalit Narayan Yadav <162928571+LalitNarayanYadav@users.noreply.github.com>
101+
Lokesh Ranjan <lokesh.ranjan.phe23@itbhu.ac.in>
92102
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
93103
MANI <77221000+Eternity0207@users.noreply.github.com>
94104
Mahfuza Humayra Mohona <mhmohona@gmail.com>
@@ -117,6 +127,7 @@ Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
117127
Oneday12323 <107678750+Oneday12323@users.noreply.github.com>
118128
Ori Miles <97595296+orimiles5@users.noreply.github.com>
119129
Philipp Burckhardt <pburckhardt@outlook.com>
130+
Pierre Forstmann <15964998+pierreforstmann@users.noreply.github.com>
120131
Prajjwal Bajpai <142303989+prajjwalbajpai@users.noreply.github.com>
121132
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
122133
Pranav Goswami <pranavchiku11@gmail.com>
@@ -146,6 +157,7 @@ Ryan Seal <splrk@users.noreply.github.com>
146157
Rylan Yang <137365285+rylany27@users.noreply.github.com>
147158
SAHIL KUMAR <168997976+sahilk45@users.noreply.github.com>
148159
SHIVAM YADAV <120725381+Shivam-1827@users.noreply.github.com>
160+
Sachin Raj <120590207+schnrj@users.noreply.github.com>
149161
Sahil Goyal <87982509+sahil20021008@users.noreply.github.com>
150162
Sai Avinash <120403424+nasarobot@users.noreply.github.com>
151163
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
@@ -166,14 +178,19 @@ Spandan Barve <contact@marsian.dev>
166178
Stephannie Jiménez Gacha <steff456@hotmail.com>
167179
Suhaib Ilahi <suhaib.elahi87@gmail.com>
168180
Suraj Kumar <125961509+kumarsuraj212003@users.noreply.github.com>
181+
Swapnil Hajare <69076366+Swapnil-2502@users.noreply.github.com>
169182
Tanishq Ahuja <68651083+TheGEN1U5@users.noreply.github.com>
170183
Tirtadwipa Manunggal <tirtadwipa.manunggal@gmail.com>
171184
Tudor Pagu <104032457+tudor-pagu@users.noreply.github.com>
172185
Tufailahmed Bargir <142114244+Tufailahmed-Bargir@users.noreply.github.com>
186+
Tushar Bhardwaj <155543597+TusharBhardwaj441@users.noreply.github.com>
187+
Uday Kakade <141299403+udaykakade25@users.noreply.github.com>
188+
Ujjwal Kirti <64329707+ujjwalkirti@users.noreply.github.com>
173189
Utkarsh <http://utkarsh11105@gmail.com>
174190
Utkarsh Raj <rajutkarsh2505@gmail.com>
175191
UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
176192
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
193+
Vara Rahul Rajana <123227543+rajanarahul93@users.noreply.github.com>
177194
Varad Gupta <varadgupta21@gmail.com>
178195
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
179196
Vivek Maurya <vm8118134@gmail.com>
@@ -182,11 +199,13 @@ Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
182199
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
183200
Yugal Kaushik <yugalkaushik14@gmail.com>
184201
Yuvi Mittal <128018763+yuvi-mittal@users.noreply.github.com>
202+
deepak427 <62477872+deepak427@users.noreply.github.com>
185203
devshree-bhati <147095250+devshree-bhati@users.noreply.github.com>
186204
ditsu <170345142+ditsus@users.noreply.github.com>
187205
ekambains <bainsinbusiness@gmail.com>
188206
fadiothman22 <48636283+fadiothman22@users.noreply.github.com>
189207
iraandrushko <71790513+iraandrushko@users.noreply.github.com>
208+
jsai28 <54253219+jsai28@users.noreply.github.com>
190209
lohithganni <116790357+lohithganni@users.noreply.github.com>
191210
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
192211
pranav-1720 <123018993+pranav-1720@users.noreply.github.com>

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 nanstdevch = require( '@stdlib/stats-base-nanstdevch' );
132132
```
133133

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

136-
Computes the [standard deviation][standard-deviation] of a strided array `x` ignoring `NaN` values and using a one-pass trial mean algorithm.
136+
Computes the [standard deviation][standard-deviation] of a strided array ignoring `NaN` values and using a one-pass trial mean 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 = nanstdevch( N, 1, x, 2 );
157+
var v = nanstdevch( 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 = nanstdevch( N, 1, x1, 2 );
171+
var v = nanstdevch( 5, 1, x1, 2 );
178172
// returns 2.5
179173
```
180174

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

183177
Computes the [standard deviation][standard-deviation] of a strided array ignoring `NaN` values and using a one-pass trial mean algorithm and alternative indexing semantics.
184178

@@ -191,17 +185,14 @@ var v = nanstdevch.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 = nanstdevch.ndarray( N, 1, x, 2, 1 );
195+
var v = nanstdevch.ndarray( 5, 1, x, 2, 1 );
205196
// returns 2.5
206197
```
207198

@@ -216,6 +207,7 @@ var v = nanstdevch.ndarray( N, 1, x, 2, 1 );
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`.
218209
- The underlying algorithm is a specialized case of Neely's two-pass algorithm. As the standard deviation is invariant with respect to changes in the location parameter, the underlying algorithm uses the first strided array element as a trial mean to shift subsequent data values and thus mitigate catastrophic cancellation. Accordingly, the algorithm's accuracy is best when data is **unordered** (i.e., the data is **not** sorted in either ascending or descending order such that the first value is an "extreme" value).
210+
- 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]).
219211
- Depending on the environment, the typed versions ([`dnanstdevch`][@stdlib/stats/strided/dnanstdevch], [`snanstdevch`][@stdlib/stats/base/snanstdevch], etc.) are likely to be significantly more performant.
220212

221213
</section>
@@ -229,18 +221,19 @@ var v = nanstdevch.ndarray( N, 1, x, 2, 1 );
229221
<!-- eslint no-undef: "error" -->
230222

231223
```javascript
232-
var randu = require( '@stdlib/random-base-randu' );
233-
var round = require( '@stdlib/math-base-special-round' );
234-
var Float64Array = require( '@stdlib/array-float64' );
224+
var uniform = require( '@stdlib/random-base-uniform' );
225+
var filledarrayBy = require( '@stdlib/array-filled-by' );
226+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
235227
var nanstdevch = require( '@stdlib/stats-base-nanstdevch' );
236228

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

246239
var v = nanstdevch( x.length, 1, x, 1 );
@@ -362,6 +355,8 @@ Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
362355

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

358+
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/array-base-accessor
359+
365360
[@neely:1966a]: https://doi.org/10.1145/365719.365958
366361

367362
[@ling:1974a]: https://doi.org/10.2307/2286154

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 nanstdevch = require( './../lib/nanstdevch.js' );
30+
var nanstdevch = 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 nanstdevch = require( './../lib/nanstdevch.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 nanstdevch = 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 nanstdevch = 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 ) {

0 commit comments

Comments
 (0)