Skip to content

Commit 5352d04

Browse files
committed
docs: update readme
1 parent 76732c8 commit 5352d04

File tree

1 file changed

+113
-21
lines changed
  • lib/node_modules/@stdlib/stats/base/dnanmeanpw

1 file changed

+113
-21
lines changed

lib/node_modules/@stdlib/stats/base/dnanmeanpw/README.md

Lines changed: 113 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,25 @@ Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-p
5959
var Float64Array = require( '@stdlib/array/float64' );
6060

6161
var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
62-
var N = x.length;
6362

64-
var v = dnanmeanpw( N, x, 1 );
63+
var v = dnanmeanpw( x.length, x, 1 );
6564
// returns ~0.3333
6665
```
6766

6867
The function has the following parameters:
6968

7069
- **N**: number of indexed elements.
7170
- **x**: input [`Float64Array`][@stdlib/array/float64].
72-
- **stride**: index increment for `x`.
71+
- **strideX**: stride length for `x`.
7372

74-
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`,
73+
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`,
7574

7675
```javascript
7776
var Float64Array = require( '@stdlib/array/float64' );
78-
var floor = require( '@stdlib/math/base/special/floor' );
7977

8078
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] );
81-
var N = floor( x.length / 2 );
8279

83-
var v = dnanmeanpw( N, x, 2 );
80+
var v = dnanmeanpw( 4, x, 2 );
8481
// returns 1.25
8582
```
8683

@@ -90,45 +87,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
9087

9188
```javascript
9289
var Float64Array = require( '@stdlib/array/float64' );
93-
var floor = require( '@stdlib/math/base/special/floor' );
9490

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

98-
var N = floor( x0.length / 2 );
99-
100-
var v = dnanmeanpw( N, x1, 2 );
94+
var v = dnanmeanpw( 4, x1, 2 );
10195
// returns 1.25
10296
```
10397

104-
#### dnanmeanpw.ndarray( N, x, stride, offset )
98+
#### dnanmeanpw.ndarray( N, x, strideX, offsetX )
10599

106100
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array, ignoring `NaN` values and using pairwise summation and alternative indexing semantics.
107101

108102
```javascript
109103
var Float64Array = require( '@stdlib/array/float64' );
110104

111105
var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
112-
var N = x.length;
113106

114-
var v = dnanmeanpw.ndarray( N, x, 1, 0 );
107+
var v = dnanmeanpw.ndarray( x.length, x, 1, 0 );
115108
// returns ~0.33333
116109
```
117110

118111
The function has the following additional parameters:
119112

120-
- **offset**: starting index for `x`.
113+
- **offsetX**: starting index for `x`.
121114

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
123116

124117
```javascript
125118
var Float64Array = require( '@stdlib/array/float64' );
126-
var floor = require( '@stdlib/math/base/special/floor' );
127119

128120
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
129-
var N = floor( x.length / 2 );
130121

131-
var v = dnanmeanpw.ndarray( N, x, 2, 1 );
122+
var v = dnanmeanpw.ndarray( 4, x, 2, 1 );
132123
// returns 1.25
133124
```
134125

@@ -181,6 +172,107 @@ console.log( v );
181172

182173
<!-- /.examples -->
183174

175+
<!-- C usage documentation. -->
176+
177+
<section class="usage">
178+
179+
### Usage
180+
181+
```c
182+
#include "stdlib/stats/base/dnanmeanpw.h"
183+
```
184+
185+
#### stdlib_strided_dnanmeanpw( N, \*X, strideX )
186+
187+
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array, ignoring `NaN` values and using pairwise summation.
188+
189+
```c
190+
const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
191+
192+
double v = stdlib_strided_dnanmeanpw( 4, x, 1 );
193+
// returns ~0.3333
194+
```
195+
196+
The function accepts the following arguments:
197+
198+
- **N**: `[in] CBLAS_INT` number of indexed elements.
199+
- **X**: `[in] double*` input array.
200+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
201+
202+
```c
203+
double stdlib_strided_dnanmeanpw( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
204+
```
205+
206+
#### stdlib_strided_dnanmeanpw_ndarray( N, \*X, strideX, offsetX )
207+
208+
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array, ignoring `NaN` values and using pairwise summation and alternative indexing semantics.
209+
210+
```c
211+
const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
212+
213+
double v = stdlib_strided_dnanmeanpw_ndarray( 4, x, 1, 0 );
214+
// returns ~0.3333
215+
```
216+
217+
The function accepts the following arguments:
218+
219+
- **N**: `[in] CBLAS_INT` number of indexed elements.
220+
- **X**: `[in] double*` input array.
221+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
222+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
223+
224+
```c
225+
double stdlib_strided_dnanmeanpw_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
226+
```
227+
228+
</section>
229+
230+
<!-- /.usage -->
231+
232+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
233+
234+
<section class="notes">
235+
236+
</section>
237+
238+
<!-- /.notes -->
239+
240+
<!-- C API usage examples. -->
241+
242+
<section class="examples">
243+
244+
### Examples
245+
246+
```c
247+
#include "stdlib/stats/base/dnanmeanpw.h"
248+
#include <stdio.h>
249+
250+
int main( void ) {
251+
// Create a strided array:
252+
const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
253+
254+
// Specify the number of elements:
255+
const int N = 6;
256+
257+
// Specify the stride length:
258+
const int strideX = 2;
259+
260+
// Compute the arithmetic mean:
261+
double v = stdlib_strided_dnanmeanpw( N, x, strideX );
262+
263+
// Print the result:
264+
printf( "mean: %lf\n", v );
265+
}
266+
```
267+
268+
</section>
269+
270+
<!-- /.examples -->
271+
272+
</section>
273+
274+
<!-- /.c -->
275+
184276
* * *
185277
186278
<section class="references">
@@ -201,7 +293,7 @@ console.log( v );
201293
202294
## See Also
203295
204-
- <span class="package-name">[`@stdlib/stats/base/dmeanpw`][@stdlib/stats/base/dmeanpw]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array using pairwise summation.</span>
296+
- <span class="package-name">[`@stdlib/stats/base/dnanmeanpw`][@stdlib/stats/base/dnanmeanpw]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array using pairwise summation.</span>
205297
- <span class="package-name">[`@stdlib/stats/base/dnanmean`][@stdlib/stats/base/dnanmean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array, ignoring NaN values.</span>
206298
207299
</section>
@@ -222,7 +314,7 @@ console.log( v );
222314
223315
<!-- <related-links> -->
224316
225-
[@stdlib/stats/base/dmeanpw]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dmeanpw
317+
[@stdlib/stats/base/dnanmeanpw]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dnanmeanpw
226318
227319
[@stdlib/stats/base/dnanmean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dnanmean
228320

0 commit comments

Comments
 (0)