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,7 +4,17 @@
4
4
5
5
<sectionclass="release"id="unreleased">
6
6
7
-
## Unreleased (2025-06-23)
7
+
## Unreleased (2025-08-13)
8
+
9
+
<sectionclass="features">
10
+
11
+
### Features
12
+
13
+
-[`03fa864`](https://github.com/stdlib-js/stdlib/commit/03fa864694becb2d5bf705033dd106c5fdc2566b) - add C ndarray interface and refactor implementation for `stats/base/snanmean`[(#7705)](https://github.com/stdlib-js/stdlib/pull/7705)
14
+
15
+
</section>
16
+
17
+
<!-- /.features -->
8
18
9
19
<sectionclass="bug-fixes">
10
20
@@ -22,6 +32,7 @@
22
32
23
33
<details>
24
34
35
+
-[`03fa864`](https://github.com/stdlib-js/stdlib/commit/03fa864694becb2d5bf705033dd106c5fdc2566b) - **feat:** add C ndarray interface and refactor implementation for `stats/base/snanmean`[(#7705)](https://github.com/stdlib-js/stdlib/pull/7705)_(by Gururaj Gurram, Athan Reines, stdlib-bot)_
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
106
+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
var floor =require( '@stdlib/math-base-special-floor' );
127
123
128
-
var x0 =newFloat32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
124
+
var x0 =newFloat32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
129
125
var x1 =newFloat32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
130
126
131
-
varN=floor( x0.length/2 );
132
-
133
-
var v =snanmean( N, x1, 2 );
127
+
var v =snanmean( 5, x1, 2 );
134
128
// returns 1.25
135
129
```
136
130
137
-
#### snanmean.ndarray( N, x, stride, offset )
131
+
#### snanmean.ndarray( N, x, strideX, offsetX )
138
132
139
133
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
var x =newFloat32Array( [ 1.0, -2.0, NaN, 2.0 ] );
145
-
varN=x.length;
146
139
147
-
var v =snanmean.ndarray( N, x, 1, 0 );
140
+
var v =snanmean.ndarray( x.length, x, 1, 0 );
148
141
// returns ~0.33333
149
142
```
150
143
151
144
The function has the following additional parameters:
152
145
153
-
-**offset**: starting index for `x`.
146
+
-**offsetX**: starting index.
147
+
148
+
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 [arithmetic mean][arithmetic-mean] for every other element in `x` starting from the second element
154
149
155
-
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 [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value
var snanmean =require( '@stdlib/stats-base-snanmean' );
194
187
195
-
var x;
196
-
var i;
197
-
198
-
x =newFloat32Array( 10 );
199
-
for ( i =0; i <x.length; i++ ) {
200
-
if ( randu() <0.2 ) {
201
-
x[ i ] =NaN;
202
-
} else {
203
-
x[ i ] =round( (randu()*100.0) -50.0 );
188
+
functionrand() {
189
+
if ( bernoulli( 0.8 ) <1 ) {
190
+
returnNaN;
204
191
}
192
+
returnuniform( -50.0, 50.0 );
205
193
}
194
+
195
+
var x =filledarrayBy( 10, 'float32', rand );
206
196
console.log( x );
207
197
208
198
var v =snanmean( x.length, x, 1 );
@@ -213,6 +203,123 @@ console.log( v );
213
203
214
204
<!-- /.examples -->
215
205
206
+
<!-- C interface documentation. -->
207
+
208
+
* * *
209
+
210
+
<sectionclass="c">
211
+
212
+
## C APIs
213
+
214
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
215
+
216
+
<sectionclass="intro">
217
+
218
+
</section>
219
+
220
+
<!-- /.intro -->
221
+
222
+
<!-- C usage documentation. -->
223
+
224
+
<sectionclass="usage">
225
+
226
+
### Usage
227
+
228
+
```c
229
+
#include"stdlib/stats/base/snanmean.h"
230
+
```
231
+
232
+
#### stdlib_strided_snanmean( N, \*X, strideX )
233
+
234
+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values.
235
+
236
+
```c
237
+
constfloat x[] = { 1.0f, 2.0f, 3.0f, 0.0f/0.0f };
238
+
239
+
float v = stdlib_strided_snanmean( 4, x, 1 );
240
+
// returns 2.0f
241
+
```
242
+
243
+
The function accepts the following arguments:
244
+
245
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
#### stdlib_strided_snanmean_ndarray( N, \*X, strideX, offsetX )
254
+
255
+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
256
+
257
+
```c
258
+
constfloat x[] = { 1.0f, 2.0f, 3.0f, 0.0f/0.0f };
259
+
260
+
float v = stdlib_strided_snanmean_ndarray( 4, x, 1, 0 );
261
+
// returns 2.0f
262
+
```
263
+
264
+
The function accepts the following arguments:
265
+
266
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
0 commit comments