Skip to content

Commit 86a0730

Browse files
committed
Auto-generated commit
1 parent 34d43f0 commit 86a0730

30 files changed

+431
-264
lines changed

CHANGELOG.md

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

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

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

15-
- [`78fe293`](https://github.com/stdlib-js/stdlib/commit/78fe2934378bdafef9059c8b95e2befd0f076d7b) - **refactor:** update `stats/base/sstdevtk` native addon from C++ to C [(#4484)](https://github.com/stdlib-js/stdlib/pull/4484) _(by Dhruv/)_
25+
- [`f1efc7b`](https://github.com/stdlib-js/stdlib/commit/f1efc7bf70197dff5abf0e25d021ae2f33239b35) - **feat:** add C ndarray interface and refactor implementation for `stats/base/sstdevtk` [(#4683)](https://github.com/stdlib-js/stdlib/pull/4683) _(by Aayush Khanna)_
26+
- [`78fe293`](https://github.com/stdlib-js/stdlib/commit/78fe2934378bdafef9059c8b95e2befd0f076d7b) - **refactor:** update `stats/base/sstdevtk` native addon from C++ to C [(#4484)](https://github.com/stdlib-js/stdlib/pull/4484) _(by Dhruv Arvind Singh)_
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)_
1829
- [`272ae7a`](https://github.com/stdlib-js/stdlib/commit/272ae7ac5c576c68cfab1b6e304c86407faa20cd) - **docs:** remove comment _(by Athan Reines)_
@@ -28,10 +39,11 @@
2839

2940
### Contributors
3041

31-
A total of 3 people contributed to this release. Thank you to the following contributors:
42+
A total of 4 people contributed to this release. Thank you to the following contributors:
3243

44+
- Aayush Khanna
3345
- Athan Reines
34-
- Dhruv/
46+
- Dhruv Arvind Singh
3547
- Philipp Burckhardt
3648

3749
</section>

CONTRIBUTORS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Daniel Killenberger <[email protected]>
2727
Daniel Yu <[email protected]>
2828
Debashis Maharana <[email protected]>
2929
Desh Deepak Kant <[email protected]>
30+
Dhruv Arvind Singh <[email protected]>
3031
Divyansh Seth <[email protected]>
3132
Dominic Lim <[email protected]>
3233
Dominik Moritz <[email protected]>
@@ -49,6 +50,7 @@ Joey Reed <[email protected]>
4950
Jordan Gallivan <[email protected]>
5051
Joris Labie <[email protected]>
5152
Justin Dennison <[email protected]>
53+
Karan Anand <[email protected]>
5254
Karthik Prakash <[email protected]>
5355
Kohantika Nath <[email protected]>
5456
Krishnendu Das <[email protected]>
@@ -117,7 +119,7 @@ UtkershBasnet <[email protected]>
117119
Vaibhav Patel <[email protected]>
118120
Varad Gupta <[email protected]>
119121
Vinit Pandit <[email protected]>
120-
Vivek maurya <[email protected].com>
122+
Vivek Maurya <vm8118134@gmail.com>
121123
Xiaochuan Ye <[email protected]>
122124
Yaswanth Kosuru <[email protected]>
123125
Yernar Yergaziyev <[email protected]>

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Copyright (c) 2016-2024 The Stdlib Authors.
1+
Copyright (c) 2016-2025 The Stdlib Authors.

README.md

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

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

136136
Computes the [standard deviation][standard-deviation] of a single-precision floating-point strided array `x` using a one-pass textbook algorithm.
137137

138138
```javascript
139139
var Float32Array = require( '@stdlib/array-float32' );
140140

141141
var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
142-
var N = x.length;
143142

144-
var v = sstdevtk( N, 1, x, 1 );
143+
var v = sstdevtk( x.length, 1, x, 1 );
145144
// returns ~2.0817
146145
```
147146

@@ -150,18 +149,16 @@ The function has the following parameters:
150149
- **N**: number of indexed elements.
151150
- **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).
152151
- **x**: input [`Float32Array`][@stdlib/array/float32].
153-
- **stride**: index increment for `x`.
152+
- **strideX**: stride length for `x`.
154153

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

157156
```javascript
158157
var Float32Array = require( '@stdlib/array-float32' );
159-
var floor = require( '@stdlib/math-base-special-floor' );
160158

161159
var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
162-
var N = floor( x.length / 2 );
163160

164-
var v = sstdevtk( N, 1, x, 2 );
161+
var v = sstdevtk( 4, 1, x, 2 );
165162
// returns 2.5
166163
```
167164

@@ -171,45 +168,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
171168

172169
```javascript
173170
var Float32Array = require( '@stdlib/array-float32' );
174-
var floor = require( '@stdlib/math-base-special-floor' );
175171

176172
var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
177173
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
178174

179-
var N = floor( x0.length / 2 );
180-
181-
var v = sstdevtk( N, 1, x1, 2 );
175+
var v = sstdevtk( 4, 1, x1, 2 );
182176
// returns 2.5
183177
```
184178

185-
#### sstdevtk.ndarray( N, correction, x, stride, offset )
179+
#### sstdevtk.ndarray( N, correction, x, strideX, offsetX )
186180

187181
Computes the [standard deviation][standard-deviation] of a single-precision floating-point strided array using a one-pass textbook algorithm and alternative indexing semantics.
188182

189183
```javascript
190184
var Float32Array = require( '@stdlib/array-float32' );
191185

192186
var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
193-
var N = x.length;
194187

195-
var v = sstdevtk.ndarray( N, 1, x, 1, 0 );
188+
var v = sstdevtk.ndarray( x.length, 1, x, 1, 0 );
196189
// returns ~2.0817
197190
```
198191

199192
The function has the following additional parameters:
200193

201-
- **offset**: starting index for `x`.
194+
- **offsetX**: starting index for `x`.
202195

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

205198
```javascript
206199
var Float32Array = require( '@stdlib/array-float32' );
207-
var floor = require( '@stdlib/math-base-special-floor' );
208200

209201
var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
210-
var N = floor( x.length / 2 );
211202

212-
var v = sstdevtk.ndarray( N, 1, x, 2, 1 );
203+
var v = sstdevtk.ndarray( 4, 1, x, 2, 1 );
213204
// returns 2.5
214205
```
215206

@@ -236,18 +227,12 @@ var v = sstdevtk.ndarray( N, 1, x, 2, 1 );
236227
<!-- eslint no-undef: "error" -->
237228

238229
```javascript
239-
var randu = require( '@stdlib/random-base-randu' );
240-
var round = require( '@stdlib/math-base-special-round' );
241-
var Float32Array = require( '@stdlib/array-float32' );
230+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
242231
var sstdevtk = require( '@stdlib/stats-base-sstdevtk' );
243232

244-
var x;
245-
var i;
246-
247-
x = new Float32Array( 10 );
248-
for ( i = 0; i < x.length; i++ ) {
249-
x[ i ] = round( (randu()*100.0) - 50.0 );
250-
}
233+
var x = discreteUniform( 10, -50, 50, {
234+
'dtype': 'float32'
235+
});
251236
console.log( x );
252237

253238
var v = sstdevtk( x.length, 1, x, 1 );
@@ -258,6 +243,125 @@ console.log( v );
258243

259244
<!-- /.examples -->
260245

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

benchmark/benchmark.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +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' );
27-
var Float32Array = require( '@stdlib/array-float32' );
2827
var pkg = require( './../package.json' ).name;
2928
var sstdevtk = require( './../lib/sstdevtk.js' );
3029

3130

31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'float32'
35+
};
36+
37+
3238
// FUNCTIONS //
3339

3440
/**
@@ -39,13 +45,7 @@ var sstdevtk = require( './../lib/sstdevtk.js' );
3945
* @returns {Function} benchmark function
4046
*/
4147
function createBenchmark( len ) {
42-
var x;
43-
var i;
44-
45-
x = new Float32Array( len );
46-
for ( i = 0; i < x.length; i++ ) {
47-
x[ i ] = ( randu()*20.0 ) - 10.0;
48-
}
48+
var x = uniform( len, -10.0, 10.0, options );
4949
return benchmark;
5050

5151
function benchmark( b ) {

benchmark/benchmark.native.js

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

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench-harness' );
25-
var randu = require( '@stdlib/random-base-randu' );
25+
var uniform = require( '@stdlib/random-array-uniform' );
2626
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2727
var pow = require( '@stdlib/math-base-special-pow' );
28-
var Float32Array = require( '@stdlib/array-float32' );
2928
var tryRequire = require( '@stdlib/utils-try-require' );
3029
var pkg = require( './../package.json' ).name;
3130

@@ -36,6 +35,9 @@ var sstdevtk = tryRequire( resolve( __dirname, './../lib/sstdevtk.native.js' ) )
3635
var opts = {
3736
'skip': ( sstdevtk instanceof Error )
3837
};
38+
var options = {
39+
'dtype': 'float32'
40+
};
3941

4042

4143
// FUNCTIONS //
@@ -48,13 +50,7 @@ var opts = {
4850
* @returns {Function} benchmark function
4951
*/
5052
function createBenchmark( len ) {
51-
var x;
52-
var i;
53-
54-
x = new Float32Array( len );
55-
for ( i = 0; i < x.length; i++ ) {
56-
x[ i ] = ( randu()*20.0 ) - 10.0;
57-
}
53+
var x = uniform( len, -10.0, 10.0, options );
5854
return benchmark;
5955

6056
function benchmark( b ) {

0 commit comments

Comments
 (0)