Skip to content

Commit f65a5d3

Browse files
committed
Auto-generated commit
1 parent 110380a commit f65a5d3

25 files changed

+331
-181
lines changed

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-06-07)
7+
## Unreleased (2025-06-22)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`0cdbf3c`](https://github.com/stdlib-js/stdlib/commit/0cdbf3cf7d5f3c16907ea70a586a732304b6b41b) - add C ndarray interface and refactor implementation for `stats/base/dmeanstdev` [(#7409)](https://github.com/stdlib-js/stdlib/pull/7409)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`0cdbf3c`](https://github.com/stdlib-js/stdlib/commit/0cdbf3cf7d5f3c16907ea70a586a732304b6b41b) - **feat:** add C ndarray interface and refactor implementation for `stats/base/dmeanstdev` [(#7409)](https://github.com/stdlib-js/stdlib/pull/7409) _(by Gururaj Gurram, Athan Reines, stdlib-bot)_
1526
- [`76100b0`](https://github.com/stdlib-js/stdlib/commit/76100b038910770cca2f13dd6e715802e3da756c) - **refactor:** update paths _(by Gururaj Gurram)_
1627
- [`744337a`](https://github.com/stdlib-js/stdlib/commit/744337aaebfd4a9631f17765bce57a38c5374173) - **refactor:** update paths _(by Gururaj Gurram)_
1728
- [`95bdc42`](https://github.com/stdlib-js/stdlib/commit/95bdc42196643ed99f417ec1be130ca7acc6b121) - **refactor:** update `stats/base/dmeanstdev` native addon from C++ to C [(#4612)](https://github.com/stdlib-js/stdlib/pull/4612) _(by Dhruv Arvind Singh)_

CONTRIBUTORS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ 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+
Aryan Bhirud <112156883+AryanBhirud@users.noreply.github.com>
2831
Athan Reines <kgryte@gmail.com>
2932
Ayaka <73595362+USERSATOSHI@users.noreply.github.com>
3033
Bhavishy Agrawal <90029607+bhavishy2801@users.noreply.github.com>
@@ -92,6 +95,7 @@ Krishnam Agarwal <83017176+888krishnam@users.noreply.github.com>
9295
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
9396
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
9497
Lalit Narayan Yadav <162928571+LalitNarayanYadav@users.noreply.github.com>
98+
Lokesh Ranjan <lokesh.ranjan.phe23@itbhu.ac.in>
9599
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
96100
MANI <77221000+Eternity0207@users.noreply.github.com>
97101
Mahfuza Humayra Mohona <mhmohona@gmail.com>
@@ -120,6 +124,7 @@ Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
120124
Oneday12323 <107678750+Oneday12323@users.noreply.github.com>
121125
Ori Miles <97595296+orimiles5@users.noreply.github.com>
122126
Philipp Burckhardt <pburckhardt@outlook.com>
127+
Pierre Forstmann <15964998+pierreforstmann@users.noreply.github.com>
123128
Prajjwal Bajpai <142303989+prajjwalbajpai@users.noreply.github.com>
124129
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
125130
Pranav Goswami <pranavchiku11@gmail.com>

README.md

Lines changed: 142 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ var dmeanstdev = require( '@stdlib/stats-base-dmeanstdev' );
135135

136136
#### dmeanstdev( N, correction, x, strideX, out, strideOut )
137137

138-
Computes the [mean][arithmetic-mean] and [standard deviation][standard-deviation] of a double-precision floating-point strided array `x`.
138+
Computes the [mean][arithmetic-mean] and [standard deviation][standard-deviation] of a double-precision floating-point strided array.
139139

140140
```javascript
141141
var Float64Array = require( '@stdlib/array-float64' );
@@ -155,21 +155,19 @@ The function has the following parameters:
155155
- **N**: number of indexed elements.
156156
- **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).
157157
- **x**: input [`Float64Array`][@stdlib/array/float64].
158-
- **strideX**: index increment for `x`.
158+
- **strideX**: stride length for `x`.
159159
- **out**: output [`Float64Array`][@stdlib/array/float64] for storing results.
160-
- **strideOut**: index increment for `out`.
160+
- **strideOut**: stride length for `out`.
161161

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

164164
```javascript
165165
var Float64Array = require( '@stdlib/array-float64' );
166-
var floor = require( '@stdlib/math-base-special-floor' );
167166

168167
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
169168
var out = new Float64Array( 2 );
170-
var N = floor( x.length / 2 );
171169

172-
var v = dmeanstdev( N, 1, x, 2, out, 1 );
170+
var v = dmeanstdev( 4, 1, x, 2, out, 1 );
173171
// returns <Float64Array>[ 1.25, 2.5 ]
174172
```
175173

@@ -179,17 +177,14 @@ Note that indexing is relative to the first index. To introduce an offset, use [
179177

180178
```javascript
181179
var Float64Array = require( '@stdlib/array-float64' );
182-
var floor = require( '@stdlib/math-base-special-floor' );
183180

184181
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
185182
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
186183

187184
var out0 = new Float64Array( 4 );
188185
var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at 3rd element
189186

190-
var N = floor( x0.length / 2 );
191-
192-
var v = dmeanstdev( N, 1, x1, 2, out1, 1 );
187+
var v = dmeanstdev( 4, 1, x1, 2, out1, 1 );
193188
// returns <Float64Array>[ 1.25, 2.5 ]
194189
```
195190

@@ -212,17 +207,15 @@ The function has the following additional parameters:
212207
- **offsetX**: starting index for `x`.
213208
- **offsetOut**: starting index for `out`.
214209

215-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameters support indexing semantics based on a starting index. For example, to calculate the [mean][arithmetic-mean] and [standard deviation][standard-deviation] for every other value in `x` starting from the second value
210+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to calculate the [mean][arithmetic-mean] and [standard deviation][standard-deviation] for every other element in `x` starting from the second element
216211

217212
```javascript
218213
var Float64Array = require( '@stdlib/array-float64' );
219-
var floor = require( '@stdlib/math-base-special-floor' );
220214

221215
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
222216
var out = new Float64Array( 4 );
223-
var N = floor( x.length / 2 );
224217

225-
var v = dmeanstdev.ndarray( N, 1, x, 2, 1, out, 2, 1 );
218+
var v = dmeanstdev.ndarray( 4, 1, x, 2, 1, out, 2, 1 );
226219
// returns <Float64Array>[ 0.0, 1.25, 0.0, 2.5 ]
227220
```
228221

@@ -248,22 +241,16 @@ var v = dmeanstdev.ndarray( N, 1, x, 2, 1, out, 2, 1 );
248241
<!-- eslint no-undef: "error" -->
249242

250243
```javascript
251-
var randu = require( '@stdlib/random-base-randu' );
252-
var round = require( '@stdlib/math-base-special-round' );
244+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
253245
var Float64Array = require( '@stdlib/array-float64' );
254246
var dmeanstdev = require( '@stdlib/stats-base-dmeanstdev' );
255247

256-
var out;
257-
var x;
258-
var i;
259-
260-
x = new Float64Array( 10 );
261-
for ( i = 0; i < x.length; i++ ) {
262-
x[ i ] = round( (randu()*100.0) - 50.0 );
263-
}
248+
var x = discreteUniform( 10, -50, 50, {
249+
'dtype': 'float64'
250+
});
264251
console.log( x );
265252

266-
out = new Float64Array( 2 );
253+
var out = new Float64Array( 2 );
267254
dmeanstdev( x.length, 1, x, 1, out, 1 );
268255
console.log( out );
269256
```
@@ -272,6 +259,135 @@ console.log( out );
272259

273260
<!-- /.examples -->
274261

262+
<!-- C interface documentation. -->
263+
264+
* * *
265+
266+
<section class="c">
267+
268+
## C APIs
269+
270+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
271+
272+
<section class="intro">
273+
274+
</section>
275+
276+
<!-- /.intro -->
277+
278+
<!-- C usage documentation. -->
279+
280+
<section class="usage">
281+
282+
### Usage
283+
284+
```c
285+
#include "stdlib/stats/base/dmeanstdev.h"
286+
```
287+
288+
#### stdlib_strided_dmeanstdev( N, correction, \*X, strideX, \*Out, strideOut )
289+
290+
Computes the [mean][arithmetic-mean] and [standard deviation][standard-deviation] of a double-precision floating-point strided array.
291+
292+
```c
293+
const double x[] = { 1.0, -2.0, 2.0 };
294+
double out[] = { 0.0, 0.0 };
295+
296+
stdlib_strided_dmeanstdev( 4, 1.0, x, 1, out, 1 );
297+
```
298+
299+
The function accepts the following arguments:
300+
301+
- **N**: `[in] CBLAS_INT` number of indexed elements.
302+
- **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 [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).
303+
- **X**: `[in] double*` input array.
304+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
305+
- **Out**: `[out] double*` output array.
306+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
307+
308+
```c
309+
void stdlib_strided_dmeanstdev( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT strideOut );
310+
```
311+
312+
#### stdlib_strided_dmeanstdev_ndarray( N, correction, \*X, strideX, offsetX, \*Out, strideOut, offsetOut )
313+
314+
Computes the [mean][arithmetic-mean] and [standard deviation][standard-deviation] of a double-precision floating-point strided array using alternative indexing semantics.
315+
316+
```c
317+
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
318+
double out[] = { 0.0, 0.0 };
319+
320+
stdlib_strided_dmeanstdev_ndarray( 4, 1.0, x, 2, 0, x, 1, 0 );
321+
```
322+
323+
The function accepts the following arguments:
324+
325+
- **N**: `[in] CBLAS_INT` number of indexed elements.
326+
- **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 [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).
327+
- **X**: `[in] double*` input array.
328+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
329+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
330+
- **Out**: `[out] double*` output array.
331+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
332+
- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`.
333+
334+
```c
335+
void stdlib_strided_dmeanstdev_ndarray( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut );
336+
```
337+
338+
</section>
339+
340+
<!-- /.usage -->
341+
342+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
343+
344+
<section class="notes">
345+
346+
</section>
347+
348+
<!-- /.notes -->
349+
350+
<!-- C API usage examples. -->
351+
352+
<section class="examples">
353+
354+
### Examples
355+
356+
```c
357+
#include "stdlib/stats/base/dmeanstdev.h"
358+
#include <stdio.h>
359+
360+
int main( void ) {
361+
// Create a strided array:
362+
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
363+
364+
// Create an output array:
365+
double out[] = { 0.0, 0.0 };
366+
367+
// Specify the number of elements:
368+
const int N = 4;
369+
370+
// Specify the stride length:
371+
const int strideX = 2;
372+
const int strideOut = 1;
373+
374+
// Compute the mean and standard deviation:
375+
stdlib_strided_dmeanstdev( N, 1.0, x, strideX, out, strideOut );
376+
377+
// Print the result:
378+
printf( "sample mean: %lf\n", out[ 0 ] );
379+
printf( "sample standard deviation: %lf\n", out[ 1 ] );
380+
}
381+
```
382+
383+
</section>
384+
385+
<!-- /.examples -->
386+
387+
</section>
388+
389+
<!-- /.c -->
390+
275391
<section class="references">
276392
277393
</section>

benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
2524
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2625
var pow = require( '@stdlib/math-base-special-pow' );
2726
var Float64Array = require( '@stdlib/array-float64' );
27+
var uniform = require( '@stdlib/random-array-uniform' );
2828
var pkg = require( './../package.json' ).name;
2929
var dmeanstdev = require( './../lib/dmeanstdev.js' );
3030

3131

32+
// VARIABLES //
33+
34+
var options = {
35+
'dtype': 'float64'
36+
};
37+
38+
3239
// FUNCTIONS //
3340

3441
/**
@@ -41,12 +48,8 @@ var dmeanstdev = require( './../lib/dmeanstdev.js' );
4148
function createBenchmark( len ) {
4249
var out;
4350
var x;
44-
var i;
4551

46-
x = new Float64Array( len );
47-
for ( i = 0; i < x.length; i++ ) {
48-
x[ i ] = ( randu()*20.0 ) - 10.0;
49-
}
52+
x = uniform( len, -10.0, 10.0, options );
5053
out = new Float64Array( 2 );
5154
return benchmark;
5255

benchmark/benchmark.native.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench-harness' );
25-
var randu = require( '@stdlib/random-base-randu' );
2625
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2726
var pow = require( '@stdlib/math-base-special-pow' );
2827
var Float64Array = require( '@stdlib/array-float64' );
28+
var uniform = require( '@stdlib/random-array-uniform' );
2929
var tryRequire = require( '@stdlib/utils-try-require' );
3030
var pkg = require( './../package.json' ).name;
3131

@@ -36,6 +36,9 @@ var dmeanstdev = tryRequire( resolve( __dirname, './../lib/dmeanstdev.native.js'
3636
var opts = {
3737
'skip': ( dmeanstdev instanceof Error )
3838
};
39+
var options = {
40+
'dtype': 'float64'
41+
};
3942

4043

4144
// FUNCTIONS //
@@ -50,12 +53,8 @@ var opts = {
5053
function createBenchmark( len ) {
5154
var out;
5255
var x;
53-
var i;
5456

55-
x = new Float64Array( len );
56-
for ( i = 0; i < x.length; i++ ) {
57-
x[ i ] = ( randu()*20.0 ) - 10.0;
58-
}
57+
x = uniform( len, -10.0, 10.0, options );
5958
out = new Float64Array( 2 );
6059
return benchmark;
6160

0 commit comments

Comments
 (0)