You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,25 @@
4
4
5
5
<sectionclass="release"id="unreleased">
6
6
7
-
## Unreleased (2025-03-10)
7
+
## Unreleased (2025-03-16)
8
+
9
+
<sectionclass="features">
10
+
11
+
### Features
12
+
13
+
-[`c155eb0`](https://github.com/stdlib-js/stdlib/commit/c155eb0820f1938b7ff56a719b72a442ccc202a1) - add C ndarray interface and refactor implementation for `stats/base/dsvariance`[(#5641)](https://github.com/stdlib-js/stdlib/pull/5641)
14
+
15
+
</section>
16
+
17
+
<!-- /.features -->
8
18
9
19
<sectionclass="commits">
10
20
11
21
### Commits
12
22
13
23
<details>
14
24
25
+
-[`c155eb0`](https://github.com/stdlib-js/stdlib/commit/c155eb0820f1938b7ff56a719b72a442ccc202a1) - **feat:** add C ndarray interface and refactor implementation for `stats/base/dsvariance`[(#5641)](https://github.com/stdlib-js/stdlib/pull/5641)_(by Prashant Kumar Yadav, stdlib-bot)_
15
26
-[`6d3a881`](https://github.com/stdlib-js/stdlib/commit/6d3a881e8df45f6c90f52af25666142603f59ca5) - **refactor:** update `stats/base/dsvariance` native addon from C++ to C [(#4868)](https://github.com/stdlib-js/stdlib/pull/4868)_(by Prashant Kumar Yadav)_
16
27
-[`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
17
28
-[`9e689ff`](https://github.com/stdlib-js/stdlib/commit/9e689ffcb7c6223afc521f1e574b42f10921cf5e) - **chore:** fix indentation in manifest.json files _(by Philipp Burckhardt)_
@@ -131,17 +131,16 @@ To view installation and usage instructions specific to each branch build, be su
131
131
var dsvariance =require( '@stdlib/stats-base-dsvariance' );
132
132
```
133
133
134
-
#### dsvariance( N, correction, x, stride )
134
+
#### dsvariance( N, correction, x, strideX )
135
135
136
-
Computes the [variance][variance] of a single-precision floating-point strided array `x`using extended accumulation and returning an extended precision result.
136
+
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and returning an extended precision result.
@@ -150,18 +149,16 @@ The function has the following parameters:
150
149
-**N**: number of indexed elements.
151
150
-**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).
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`,
var x1 =newFloat32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
178
174
179
-
varN=floor( x0.length/2 );
180
-
181
-
var v =dsvariance( N, 1, x1, 2 );
175
+
var v =dsvariance( 4, 1, x1, 2 );
182
176
// returns 6.25
183
177
```
184
178
185
-
#### dsvariance.ndarray( N, correction, x, stride, offset )
179
+
#### dsvariance.ndarray( N, correction, x, strideX, offsetX )
186
180
187
181
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
var v =dsvariance.ndarray( x.length, 1, x, 1, 0 );
196
189
// returns ~4.33333
197
190
```
198
191
199
192
The function has the following additional parameters:
200
193
201
-
-**offset**: starting index for `x`.
194
+
-**offsetX**: starting index for `x`.
202
195
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 [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
var discreteUniform =require( '@stdlib/random-array-discrete-uniform' );
242
231
var dsvariance =require( '@stdlib/stats-base-dsvariance' );
243
232
244
-
var x;
245
-
var i;
246
-
247
-
x =newFloat32Array( 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
+
});
251
236
console.log( x );
252
237
253
238
var v =dsvariance( x.length, 1, x, 1 );
@@ -258,6 +243,127 @@ console.log( v );
258
243
259
244
<!-- /.examples -->
260
245
246
+
<!-- C interface documentation. -->
247
+
248
+
* * *
249
+
250
+
<sectionclass="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
+
<sectionclass="intro">
257
+
258
+
</section>
259
+
260
+
<!-- /.intro -->
261
+
262
+
<!-- C usage documentation. -->
263
+
264
+
<sectionclass="usage">
265
+
266
+
### Usage
267
+
268
+
```c
269
+
#include"stdlib/stats/base/dsvariance.h"
270
+
```
271
+
272
+
#### stdlib_strided_dsvariance( N, correction, \*X, strideX )
273
+
274
+
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and returning an extended precision result.
double v = stdlib_strided_dsvariance( 8, 1.0f, x, 1 );
280
+
// returns 6.0
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 [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).
287
+
- **X**: `[in] float*` input array.
288
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dsvariance_ndarray( N, correction, \*X, strideX, offsetX )
295
+
296
+
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
double v = stdlib_strided_dsvariance_ndarray( 4, 1.0f, x, 2, 0 );
302
+
// returns ~6.666667
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 [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).
309
+
- **X**: `[in] float*` input array.
310
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
311
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments