Skip to content

Commit ffe8e17

Browse files
committed
Auto-generated commit
1 parent e30563a commit ffe8e17

31 files changed

+496
-329
lines changed

.github/.keepalive

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

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dnanvariancech) of the main repository where we’ll review and provide feedback.
44

5-
If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib.
5+
If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib.
66

77
We look forward to receiving your contribution! :smiley:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,7 @@ jsconfig.json
188188
# Other editor files #
189189
######################
190190
.idea/
191+
192+
# Cursor #
193+
##########
194+
.cursorignore

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-01-20)
7+
## Unreleased (2025-02-23)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`00b23b3`](https://github.com/stdlib-js/stdlib/commit/00b23b3cb5b4e72bf977a9ac170062f8e8614ef1) - add C ndarray interface and refactor implementation for `stats/base/dnanvariancech` [(#4803)](https://github.com/stdlib-js/stdlib/pull/4803)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`00b23b3`](https://github.com/stdlib-js/stdlib/commit/00b23b3cb5b4e72bf977a9ac170062f8e8614ef1) - **feat:** add C ndarray interface and refactor implementation for `stats/base/dnanvariancech` [(#4803)](https://github.com/stdlib-js/stdlib/pull/4803) _(by Prashant Kumar Yadav)_
1526
- [`ca5cd8e`](https://github.com/stdlib-js/stdlib/commit/ca5cd8eda51ba2c274b9aeb0161f6c1cdf6a3e09) - **refactor:** update `stats/base/dnanvariancech` native addon from C++ to C [(#4719)](https://github.com/stdlib-js/stdlib/pull/4719) _(by Prashant Kumar Yadav)_
1627
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
1728
- [`9e689ff`](https://github.com/stdlib-js/stdlib/commit/9e689ffcb7c6223afc521f1e574b42f10921cf5e) - **chore:** fix indentation in manifest.json files _(by Philipp Burckhardt)_

CONTRIBUTORS

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Aadish Jain <[email protected]>
66
Aayush Khanna <[email protected]>
77
Abhijit Raut <[email protected]>
8+
Abhishek Jain <[email protected]>
89
Adarsh Palaskar <[email protected]>
910
Aditya Sapra <[email protected]>
1011
Ahmed Atwa <[email protected]>
@@ -35,9 +36,12 @@ Dominik Moritz <[email protected]>
3536
Dorrin Sotoudeh <[email protected]>
3637
EuniceSim142 <[email protected]>
3738
Frank Kovacs <[email protected]>
39+
GK Bishnoi <[email protected]>
40+
3841
Golden Kumar <[email protected]>
3942
Gunj Joshi <[email protected]>
40-
Gururaj Gurram <[email protected]>
43+
Gururaj Gurram <[email protected]>
44+
4145
4246
Harshita Kalani <[email protected]>
4347
Hridyanshu <[email protected]>
@@ -54,6 +58,7 @@ Justin Dennison <[email protected]>
5458
Karan Anand <[email protected]>
5559
Karthik Prakash <[email protected]>
5660
Kohantika Nath <[email protected]>
61+
Krishnam Agarwal <[email protected]>
5762
Krishnendu Das <[email protected]>
5863
Kshitij-Dale <[email protected]>
5964
Lovelin Dhoni J B <[email protected]>
@@ -63,6 +68,7 @@ Marcus Fantham <[email protected]>
6368
Matt Cochrane <[email protected]>
6469
Mihir Pandit <[email protected]>
6570
Milan Raj <[email protected]>
71+
Mohammad Bin Aftab <[email protected]>
6672
Mohammad Kaif <[email protected]>
6773
Momtchil Momtchev <[email protected]>
6874
Muhammad Haris <[email protected]>
@@ -90,6 +96,7 @@ Rejoan Sardar <[email protected]>
9096
Ricky Reusser <[email protected]>
9197
Ridam Garg <[email protected]>
9298
99+
Rishav Tarway <[email protected]>
93100
Robert Gislason <[email protected]>
94101
Roman Stetsyk <[email protected]>
95102
Rutam Kathale <[email protected]>
@@ -100,6 +107,7 @@ Sai Srikar Dumpeti <[email protected]>
100107
Sarthak Paandey <[email protected]>
101108
Saurabh Singh <[email protected]>
102109
Seyyed Parsa Neshaei <[email protected]>
110+
Shabareesh Shetty <[email protected]>
103111
Shashank Shekhar Singh <[email protected]>
104112
Shivam Ahir <[email protected]>
105113
Shraddheya Shendre <[email protected]>
@@ -110,6 +118,7 @@ Snehil Shah <[email protected]>
110118
Soumajit Chatterjee <[email protected]>
111119
Spandan Barve <[email protected]>
112120
Stephannie Jiménez Gacha <[email protected]>
121+
Suhaib Ilahi <[email protected]>
113122
Suraj Kumar <[email protected]>
114123
Tirtadwipa Manunggal <[email protected]>
115124
Tudor Pagu <[email protected]>
@@ -124,6 +133,9 @@ Vivek Maurya <[email protected]>
124133
Xiaochuan Ye <[email protected]>
125134
Yaswanth Kosuru <[email protected]>
126135
Yernar Yergaziyev <[email protected]>
136+
Yuvi Mittal <[email protected]>
137+
ekambains <[email protected]>
127138
olenkabilonizhka <[email protected]>
139+
pranav-1720 <[email protected]>
128140
129141

README.md

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

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

136136
Computes the [variance][variance] of a double-precision floating-point strided array `x` ignoring `NaN` values and using a one-pass trial mean algorithm.
137137

@@ -149,18 +149,16 @@ The function has the following parameters:
149149
- **N**: number of indexed elements.
150150
- **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 and `n` corresponds to the number of non-`NaN` indexed elements. 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).
151151
- **x**: input [`Float64Array`][@stdlib/array/float64].
152-
- **stride**: index increment for `x`.
152+
- **strideX**: stride length for `x`.
153153

154-
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`,
154+
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`,
155155

156156
```javascript
157157
var Float64Array = require( '@stdlib/array-float64' );
158-
var floor = require( '@stdlib/math-base-special-floor' );
159158

160-
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] );
161-
var N = floor( x.length / 2 );
159+
var x = new Float64Array([1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN]);
162160

163-
var v = dnanvariancech( N, 1, x, 2 );
161+
var v = dnanvariancech( 5, 1, x, 2 );
164162
// returns 6.25
165163
```
166164

@@ -170,44 +168,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
170168

171169
```javascript
172170
var Float64Array = require( '@stdlib/array-float64' );
173-
var floor = require( '@stdlib/math-base-special-floor' );
174171

175-
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
172+
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); // eslint-disable-line max-len
176173
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
177174

178-
var N = floor( x0.length / 2 );
179-
180-
var v = dnanvariancech( N, 1, x1, 2 );
175+
var v = dnanvariancech( 5, 1, x1, 2 );
181176
// returns 6.25
182177
```
183178

184-
#### dnanvariancech.ndarray( N, correction, x, stride, offset )
179+
#### dnanvariancech.ndarray( N, correction, x, strideX, offsetX )
185180

186181
Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using a one-pass trial mean algorithm and alternative indexing semantics.
187182

188183
```javascript
189184
var Float64Array = require( '@stdlib/array-float64' );
190185

191-
var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
186+
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
192187

193188
var v = dnanvariancech.ndarray( x.length, 1, x, 1, 0 );
194189
// returns ~4.33333
195190
```
196191

197192
The function has the following additional parameters:
198193

199-
- **offset**: starting index for `x`.
194+
- **offsetX**: starting index for `x`.
200195

201-
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
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 element in `x` starting from the second element
202197

203198
```javascript
204199
var Float64Array = require( '@stdlib/array-float64' );
205-
var floor = require( '@stdlib/math-base-special-floor' );
206200

207-
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
208-
var N = floor( x.length / 2 );
201+
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); // eslint-disable-line max-len
209202

210-
var v = dnanvariancech.ndarray( N, 1, x, 2, 1 );
203+
var v = dnanvariancech.ndarray( 5, 1, x, 2, 1 );
211204
// returns 6.25
212205
```
213206

@@ -234,19 +227,19 @@ var v = dnanvariancech.ndarray( N, 1, x, 2, 1 );
234227
<!-- eslint no-undef: "error" -->
235228

236229
```javascript
237-
var randu = require( '@stdlib/random-base-randu' );
238-
var round = require( '@stdlib/math-base-special-round' );
239-
var Float64Array = require( '@stdlib/array-float64' );
230+
var uniform = require( '@stdlib/random-base-uniform' );
231+
var filledarrayBy = require( '@stdlib/array-filled-by' );
232+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
240233
var dnanvariancech = require( '@stdlib/stats-base-dnanvariancech' );
241234

242-
var x;
243-
var i;
244-
245-
x = new Float64Array( 10 );
246-
for ( i = 0; i < x.length; i++ ) {
247-
x[ i ] = round( (randu()*100.0) - 50.0 );
235+
function rand() {
236+
if ( bernoulli( 0.8 ) < 1 ) {
237+
return NaN;
238+
}
239+
return uniform( -50.0, 50.0 );
248240
}
249-
console.log( x );
241+
242+
var x = filledarrayBy( 10, 'float64', rand );
250243

251244
var v = dnanvariancech( x.length, 1, x, 1 );
252245
console.log( v );
@@ -256,6 +249,125 @@ console.log( v );
256249

257250
<!-- /.examples -->
258251

252+
<!-- C interface documentation. -->
253+
254+
* * *
255+
256+
<section class="c">
257+
258+
## C APIs
259+
260+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
261+
262+
<section class="intro">
263+
264+
</section>
265+
266+
<!-- /.intro -->
267+
268+
<!-- C usage documentation. -->
269+
270+
<section class="usage">
271+
272+
### Usage
273+
274+
```c
275+
#include "stdlib/stats/base/dnanvariancech.h"
276+
```
277+
278+
#### stdlib_strided_dnanvariancech( N, correction, \*X, strideX )
279+
280+
Computes the [variance][variance] of a double-precision floating-point strided array `x` ignoring `NaN` values and using a one-pass trial mean algorithm.
281+
282+
```c
283+
const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
284+
285+
double v = stdlib_strided_dnanvariancech( 4, 1.0, x, 1 );
286+
// returns ~4.3333
287+
```
288+
289+
The function accepts the following arguments:
290+
291+
- **N**: `[in] CBLAS_INT` number of indexed elements.
292+
- **correction**: `[in] double` 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 and `n` corresponds to the number of non-`NaN` indexed elements. 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).
293+
- **X**: `[in] double*` input array.
294+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
295+
296+
```c
297+
double stdlib_strided_dnanvariancech( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX );
298+
```
299+
300+
#### stdlib_strided_dnanvariancech_ndarray( N, correction, \*X, strideX, offsetX )
301+
302+
Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using a one-pass trial mean algorithm and alternative indexing semantics.
303+
304+
```c
305+
const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
306+
307+
double v = stdlib_strided_dnanvariancech_ndarray( 4, 1.0, x, 1, 0 );
308+
// returns ~4.3333
309+
```
310+
311+
The function accepts the following arguments:
312+
313+
- **N**: `[in] CBLAS_INT` number of indexed elements.
314+
- **correction**: `[in] double` 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 and `n` corresponds to the number of non-`NaN` indexed elements. 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).
315+
- **X**: `[in] double*` input array.
316+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
317+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
318+
319+
```c
320+
double stdlib_strided_dnanvariancech_ndarray( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
321+
```
322+
323+
</section>
324+
325+
<!-- /.usage -->
326+
327+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
328+
329+
<section class="notes">
330+
331+
</section>
332+
333+
<!-- /.notes -->
334+
335+
<!-- C API usage examples. -->
336+
337+
<section class="examples">
338+
339+
### Examples
340+
341+
```c
342+
#include "stdlib/stats/base/dnanvariancech.h"
343+
#include <stdio.h>
344+
345+
int main( void ) {
346+
// Create a strided array:
347+
const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
348+
349+
// Specify the number of elements:
350+
const int N = 6;
351+
352+
// Specify the stride length:
353+
const int strideX = 2;
354+
355+
// Compute the variance:
356+
double v = stdlib_strided_dnanvariancech( N, 1, x, strideX );
357+
358+
// Print the result:
359+
printf( "sample variance: %lf\n", v );
360+
}
361+
```
362+
363+
</section>
364+
365+
<!-- /.examples -->
366+
367+
</section>
368+
369+
<!-- /.c -->
370+
259371
* * *
260372
261373
<section class="references">

0 commit comments

Comments
 (0)