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
- [`deabf53`](https://github.com/stdlib-js/stdlib/commit/deabf5358fdce4a99aa6f060e3d296a69538ed24) - add C `ndarray` interface and refactor implementation for `stats/base/dsmeanpw` [(#4338)](https://github.com/stdlib-js/stdlib/pull/4338)
Copy file name to clipboardexpand all lines: base/dsmeanpw/README.md
+115-29
Original file line number
Diff line number
Diff line change
@@ -51,36 +51,33 @@ The [arithmetic mean][arithmetic-mean] is defined as
51
51
var dsmeanpw =require( '@stdlib/stats/base/dsmeanpw' );
52
52
```
53
53
54
-
#### dsmeanpw( N, x, stride )
54
+
#### dsmeanpw( N, x, strideX )
55
55
56
56
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x` using pairwise summation with extended accumulation and returning an extended precision result.
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`,
var x1 =newFloat32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
97
93
98
-
varN=floor( x0.length/2 );
99
-
100
-
var v =dsmeanpw( N, x1, 2 );
94
+
var v =dsmeanpw( 4, x1, 2 );
101
95
// returns 1.25
102
96
```
103
97
104
-
#### dsmeanpw.ndarray( N, x, stride, offset )
98
+
#### dsmeanpw.ndarray( N, x, strideX, offsetX )
105
99
106
100
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using pairwise summation with extended accumulation and alternative indexing semantics and returning an extended precision result.
The function has the following additional parameters:
119
112
120
-
-**offset**: starting index for `x`.
113
+
-**offsetX**: starting index for `x`.
121
114
122
-
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
115
+
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
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
161
150
var dsmeanpw =require( '@stdlib/stats/base/dsmeanpw' );
162
151
163
-
var x;
164
-
var i;
165
-
166
-
x =newFloat32Array( 10 );
167
-
for ( i =0; i <x.length; i++ ) {
168
-
x[ i ] =round( (randu()*100.0) -50.0 );
169
-
}
152
+
var x =discreteUniform( 10, -50, 50, {
153
+
'dtype':'float32'
154
+
});
170
155
console.log( x );
171
156
172
157
var v =dsmeanpw( x.length, x, 1 );
@@ -177,6 +162,107 @@ console.log( v );
177
162
178
163
<!-- /.examples -->
179
164
165
+
<!-- C usage documentation. -->
166
+
167
+
<sectionclass="usage">
168
+
169
+
### Usage
170
+
171
+
```c
172
+
#include"stdlib/stats/base/dsmeanpw.h"
173
+
```
174
+
175
+
#### stdlib_strided_dsmeanpw( N, \*X, strideX )
176
+
177
+
Computes the arithmetic mean of a single-precision floating-point strided array using pairwise summation with extended accumulation and returning an extended precision result.
#### stdlib_strided_dsmeanpw_ndarray( N, \*X, strideX, offsetX )
197
+
198
+
Computes the arithmetic mean of a single-precision floating-point strided array using pairwise summation with extended accumulation and alternative indexing semantics and returning an extended precision result.
0 commit comments