Skip to content

Commit c45de9e

Browse files
committed
Auto-generated commit
1 parent af412b4 commit c45de9e

18 files changed

+598
-175
lines changed

CHANGELOG.md

Lines changed: 28 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-03-30)
7+
## Unreleased (2025-06-13)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`b711c6c`](https://github.com/stdlib-js/stdlib/commit/b711c6cfd9e1c9735e0c9aa193ec28a3771eb233) - add support for accessor arrays and refactor `stats/base/variancech` [(#5998)](https://github.com/stdlib-js/stdlib/pull/5998)
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+
[#5688](https://github.com/stdlib-js/stdlib/issues/5688)
26+
27+
</section>
28+
29+
<!-- /.issues -->
830

931
<section class="commits">
1032

1133
### Commits
1234

1335
<details>
1436

37+
- [`b711c6c`](https://github.com/stdlib-js/stdlib/commit/b711c6cfd9e1c9735e0c9aa193ec28a3771eb233) - **feat:** add support for accessor arrays and refactor `stats/base/variancech` [(#5998)](https://github.com/stdlib-js/stdlib/pull/5998) _(by Deep Trivedi, Athan Reines, stdlib-bot, Gururaj Gurram)_
1538
- [`adfa457`](https://github.com/stdlib-js/stdlib/commit/adfa4575e7715273bb374e76860236608ca4a165) - **refactor:** update paths _(by Aayush Khanna)_
1639
- [`ab7cd64`](https://github.com/stdlib-js/stdlib/commit/ab7cd64f58fab5278c0160ad70d494fb545f6a44) - **refactor:** update paths _(by Aayush Khanna)_
1740

@@ -25,9 +48,12 @@
2548

2649
### Contributors
2750

28-
A total of 1 person contributed to this release. Thank you to this contributor:
51+
A total of 4 people contributed to this release. Thank you to the following contributors:
2952

3053
- Aayush Khanna
54+
- Athan Reines
55+
- Deep Trivedi
56+
- Gururaj Gurram
3157

3258
</section>
3359

CONTRIBUTORS

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ AlyAbdelmoneim <148393799+AlyAbdelmoneim@users.noreply.github.com>
2222
Aman Bhansali <bhansali.1@iitj.ac.in>
2323
AmanBhadkariya <140033975+AmanBhadkariya@users.noreply.github.com>
2424
Amit Jimiwal <amitjimiwal45@gmail.com>
25+
Annamalai Prabu <apfossdev@gmail.com>
2526
Anshu Kumar <132515490+anxhukumar@users.noreply.github.com>
2627
Anshu Kumar <contact.anshukumar@protonmail.com>
2728
Anudeep Sanapala <anudeep0306@gmail.com>
@@ -38,27 +39,33 @@ Daniel Killenberger <daniel.killenberger@gmail.com>
3839
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
3940
Debashis Maharana <debashismaharana7854@gmail.com>
4041
Deep Trivedi <128926685+thedeeppp@users.noreply.github.com>
42+
Deepak Singh <78257493+Deepak91168@users.noreply.github.com>
4143
Desh Deepak Kant <118960904+DeshDeepakKant@users.noreply.github.com>
4244
Dev Goel <135586571+corsairier@users.noreply.github.com>
4345
Dhanyabad behera <110620935+dhanyabad11@users.noreply.github.com>
4446
Dhruv Arvind Singh <154677013+DhruvArvindSingh@users.noreply.github.com>
4547
Dhruvil Mehta <68022411+dhruvilmehta@users.noreply.github.com>
48+
Dipjyoti Das <126075231+dipexplorer@users.noreply.github.com>
4649
Divyansh Seth <59174836+sethdivyansh@users.noreply.github.com>
4750
Dominic Lim <46486515+domlimm@users.noreply.github.com>
4851
Dominik Moritz <domoritz@gmail.com>
4952
Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
5053
EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com>
5154
Frank Kovacs <fran70kk@gmail.com>
5255
GK Bishnoi <gkishan1kyt@gmail.com>
56+
GURU PRASAD SHARMA <168292003+GURUPRASADSHARMA@users.noreply.github.com>
5357
Gaurav <gaurav70380@gmail.com>
58+
Gautam Kaushik <162317291+Kaushikgtm@users.noreply.github.com>
5459
Gautam sharma <gautamkrishnasharma1@gmail.com>
60+
Girish Garg <garggirish2020@gmail.com>
5561
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
5662
Gunj Joshi <gunjjoshi8372@gmail.com>
5763
Gururaj Gurram <gururajgurram1512@gmail.com>
5864
Haroon Rasheed <51189276+haroon26@users.noreply.github.com>
59-
Harsh <149176984+hrshya@users.noreply.github.com>
65+
Harsh <harshyadav6078@gmail.com>
6066
HarshaNP <96897754+GittyHarsha@users.noreply.github.com>
6167
Harshita Kalani <harshitakalani02@gmail.com>
68+
Hemang Choudhary <coehemang@gmail.com>
6269
Hemant M Mehta <92446645+hemantmm@users.noreply.github.com>
6370
Hridyanshu <124202756+HRIDYANSHU054@users.noreply.github.com>
6471
Jaimin Godhani <112328542+Jai0401@users.noreply.github.com>
@@ -75,16 +82,20 @@ Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
7582
Joris Labie <joris.labie1@gmail.com>
7683
Justin Dennison <justin1dennison@gmail.com>
7784
Justyn Shelby <96994781+ShelbyJustyn@users.noreply.github.com>
78-
Karan Anand <119553199+anandkaranubc@users.noreply.github.com>
85+
Karan Anand <anandkarancompsci@gmail.com>
86+
Karan Vasudevamurthy <karanlvm123@gmail.com>
87+
Karan Yadav <77043443+karanBRAVO@users.noreply.github.com>
7988
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
8089
Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
8190
Kavyansh-Bagdi <153486713+Kavyansh-Bagdi@users.noreply.github.com>
8291
Kohantika Nath <145763549+kohantikanath@users.noreply.github.com>
8392
Krishnam Agarwal <83017176+888krishnam@users.noreply.github.com>
8493
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
8594
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
95+
Lalit Narayan Yadav <162928571+LalitNarayanYadav@users.noreply.github.com>
8696
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
8797
MANI <77221000+Eternity0207@users.noreply.github.com>
98+
Mahfuza Humayra Mohona <mhmohona@gmail.com>
8899
Manik Sharma <maniksharma.rke@gmail.com>
89100
Manvith M <148960168+manvith2003@users.noreply.github.com>
90101
Marcus Fantham <mfantham@users.noreply.github.com>
@@ -95,24 +106,31 @@ Mohammad Bin Aftab <48010758+MohammadBinAftab@users.noreply.github.com>
95106
Mohammad Kaif <mdkaifprofession@gmail.com>
96107
Momtchil Momtchev <momtchil@momtchev.com>
97108
Muhammad Haris <harriskhan047@outlook.com>
109+
Muhammad Taaha Tariq <166188821+Taaha-Tariq@users.noreply.github.com>
110+
Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com>
98111
Naresh Jagadeesan <naresh.naresh000@gmail.com>
99112
Naveen Kumar <stupiddint@gmail.com>
100113
Neeraj Pathak <neerajrpathak710@gmail.com>
114+
NirvedMishra <139633597+NirvedMishra@users.noreply.github.com>
101115
Nishant Shinde <97207366+nishant-s7@users.noreply.github.com>
116+
Nishant singh <38534128+Nishantsingh11@users.noreply.github.com>
102117
Nishchay Rajput <121144841+NishchayRajput@users.noreply.github.com>
103118
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
104119
Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com>
105120
Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
106121
Oneday12323 <107678750+Oneday12323@users.noreply.github.com>
107122
Ori Miles <97595296+orimiles5@users.noreply.github.com>
108123
Philipp Burckhardt <pburckhardt@outlook.com>
124+
Pierre Forstmann <15964998+pierreforstmann@users.noreply.github.com>
109125
Prajjwal Bajpai <142303989+prajjwalbajpai@users.noreply.github.com>
110126
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
111127
Pranav Goswami <pranavchiku11@gmail.com>
112128
Pranjal Jha <97080887+PraneGIT@users.noreply.github.com>
113129
Prashant Kumar Yadav <144602492+0PrashantYadav0@users.noreply.github.com>
130+
PrathamBhamare <164445568+PrathamBhamare@users.noreply.github.com>
114131
Pratik Singh <97464067+Pratik772846@users.noreply.github.com>
115132
Pratyush Kumar Chouhan <pratyushkumar0308@gmail.com>
133+
Pravesh Kunwar <praveshkunwar04@gmail.com>
116134
Priyansh Prajapati <88396544+itsspriyansh@users.noreply.github.com>
117135
Priyanshu Agarwal <113460573+AgPriyanshu18@users.noreply.github.com>
118136
Pulkit Gupta <65711278+pulkitgupta2@users.noreply.github.com>
@@ -126,12 +144,16 @@ Rishav <115060907+rishav2404@users.noreply.github.com>
126144
Rishav Tarway <rishavtarway@gmail.com>
127145
Robert Gislason <gztown2216@yahoo.com>
128146
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
147+
Rupa <102663541+Rupa-Rd@users.noreply.github.com>
129148
Rutam Kathale <138517416+performant23@users.noreply.github.com>
130149
Ruthwik Chikoti <145591715+ruthwikchikoti@users.noreply.github.com>
131150
Ryan Seal <splrk@users.noreply.github.com>
132151
Rylan Yang <137365285+rylany27@users.noreply.github.com>
133152
SAHIL KUMAR <168997976+sahilk45@users.noreply.github.com>
134153
SHIVAM YADAV <120725381+Shivam-1827@users.noreply.github.com>
154+
Sachin Raj <120590207+schnrj@users.noreply.github.com>
155+
Sahil Goyal <87982509+sahil20021008@users.noreply.github.com>
156+
Sai Avinash <120403424+nasarobot@users.noreply.github.com>
135157
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
136158
Sanchay Ketan Sinha <122982233+satansin123@users.noreply.github.com>
137159
Sarthak Paandey <145528240+SarthakPaandey@users.noreply.github.com>
@@ -150,14 +172,19 @@ Spandan Barve <contact@marsian.dev>
150172
Stephannie Jiménez Gacha <steff456@hotmail.com>
151173
Suhaib Ilahi <suhaib.elahi87@gmail.com>
152174
Suraj Kumar <125961509+kumarsuraj212003@users.noreply.github.com>
175+
Swapnil Hajare <69076366+Swapnil-2502@users.noreply.github.com>
153176
Tanishq Ahuja <68651083+TheGEN1U5@users.noreply.github.com>
154177
Tirtadwipa Manunggal <tirtadwipa.manunggal@gmail.com>
155178
Tudor Pagu <104032457+tudor-pagu@users.noreply.github.com>
156179
Tufailahmed Bargir <142114244+Tufailahmed-Bargir@users.noreply.github.com>
180+
Tushar Bhardwaj <155543597+TusharBhardwaj441@users.noreply.github.com>
181+
Uday Kakade <141299403+udaykakade25@users.noreply.github.com>
182+
Ujjwal Kirti <64329707+ujjwalkirti@users.noreply.github.com>
157183
Utkarsh <http://utkarsh11105@gmail.com>
158184
Utkarsh Raj <rajutkarsh2505@gmail.com>
159185
UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
160186
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
187+
Vara Rahul Rajana <123227543+rajanarahul93@users.noreply.github.com>
161188
Varad Gupta <varadgupta21@gmail.com>
162189
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
163190
Vivek Maurya <vm8118134@gmail.com>
@@ -166,11 +193,15 @@ Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
166193
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
167194
Yugal Kaushik <yugalkaushik14@gmail.com>
168195
Yuvi Mittal <128018763+yuvi-mittal@users.noreply.github.com>
196+
devshree-bhati <147095250+devshree-bhati@users.noreply.github.com>
169197
ditsu <170345142+ditsus@users.noreply.github.com>
170198
ekambains <bainsinbusiness@gmail.com>
171199
fadiothman22 <48636283+fadiothman22@users.noreply.github.com>
200+
iraandrushko <71790513+iraandrushko@users.noreply.github.com>
201+
lohithganni <116790357+lohithganni@users.noreply.github.com>
172202
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
173203
pranav-1720 <123018993+pranav-1720@users.noreply.github.com>
174204
rahulrangers <127782777+rahulrangers@users.noreply.github.com>
175205
rainn <88160429+AmCodesLame@users.noreply.github.com>
176206
rei2hu <reimu@reimu.ws>
207+
zhanggy <geodaoyu@foxmail.com>

README.md

Lines changed: 17 additions & 29 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 variancech = require( '@stdlib/stats-base-variancech' );
132132
```
133133

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

136-
Computes the [variance][variance] of a strided array `x` using a one-pass trial mean algorithm.
136+
Computes the [variance][variance] of a strided array using a one-pass trial mean algorithm.
137137

138138
```javascript
139139
var x = [ 1.0, -2.0, 2.0 ];
@@ -147,17 +147,14 @@ 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 [variance][variance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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

152-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`,
152+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [variance][variance] 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 ];
158-
var N = floor( x.length / 2 );
159156

160-
var v = variancech( N, 1, x, 2 );
157+
var v = variancech( 4, 1, x, 2 );
161158
// returns 6.25
162159
```
163160

@@ -167,18 +164,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [
167164

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

172168
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
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 = variancech( N, 1, x1, 2 );
171+
var v = variancech( 4, 1, x1, 2 );
178172
// returns 6.25
179173
```
180174

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

183177
Computes the [variance][variance] of a strided array using a one-pass trial mean algorithm and alternative indexing semantics.
184178

@@ -191,17 +185,14 @@ var v = variancech.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 [variance][variance] 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 [variance][variance] for every other element in `x` starting from the second element
197191

198192
```javascript
199-
var floor = require( '@stdlib/math-base-special-floor' );
200-
201193
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 );
203194

204-
var v = variancech.ndarray( N, 1, x, 2, 1 );
195+
var v = variancech.ndarray( 4, 1, x, 2, 1 );
205196
// returns 6.25
206197
```
207198

@@ -216,6 +207,7 @@ var v = variancech.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), both functions return `NaN`.
218209
- The underlying algorithm is a specialized case of Neely's two-pass algorithm. As the variance 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 ([`dvariancech`][@stdlib/stats/strided/dvariancech], [`svariancech`][@stdlib/stats/strided/svariancech], etc.) are likely to be significantly more performant.
220212

221213
</section>
@@ -229,18 +221,12 @@ var v = variancech.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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
235225
var variancech = require( '@stdlib/stats-base-variancech' );
236226

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 );
243-
}
227+
var x = discreteUniform( 10, -50, 50, {
228+
'dtype': 'float64'
229+
});
244230
console.log( x );
245231

246232
var v = variancech( x.length, 1, x, 1 );
@@ -361,6 +347,8 @@ Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
361347

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

350+
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/array-base-accessor
351+
364352
[@stdlib/stats/strided/svariancech]: https://github.com/stdlib-js/stats-strided-svariancech
365353

366354
[@neely:1966a]: https://doi.org/10.1145/365719.365958

benchmark/benchmark.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-array-uniform' );
2525
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2626
var pow = require( '@stdlib/math-base-special-pow' );
2727
var pkg = require( './../package.json' ).name;
28-
var variancech = require( './../lib/variancech.js' );
28+
var variancech = require( './../lib/main.js' );
29+
30+
31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'generic'
35+
};
2936

3037

3138
// FUNCTIONS //
@@ -38,13 +45,7 @@ var variancech = require( './../lib/variancech.js' );
3845
* @returns {Function} benchmark function
3946
*/
4047
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = [];
45-
for ( i = 0; i < len; i++ ) {
46-
x.push( ( randu()*20.0 ) - 10.0 );
47-
}
48+
var x = uniform( len, -10, 10, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

benchmark/benchmark.ndarray.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-array-uniform' );
2525
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2626
var pow = require( '@stdlib/math-base-special-pow' );
2727
var pkg = require( './../package.json' ).name;
2828
var variancech = require( './../lib/ndarray.js' );
2929

3030

31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'generic'
35+
};
36+
37+
3138
// FUNCTIONS //
3239

3340
/**
@@ -38,13 +45,7 @@ var variancech = require( './../lib/ndarray.js' );
3845
* @returns {Function} benchmark function
3946
*/
4047
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = [];
45-
for ( i = 0; i < len; i++ ) {
46-
x.push( ( randu()*20.0 ) - 10.0 );
47-
}
48+
var x = uniform( len, -10, 10, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

0 commit comments

Comments
 (0)