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
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@develop/lib/node_modules/%40stdlib/stats/base/ndarray/meankbn/docs/img/equation_arithmetic_mean.svg" alt="Equation for the arithmetic mean.">
37
+
<br>
38
+
</div> -->
39
+
40
+
<!-- </equation> -->
41
+
42
+
This package provides an ndarray wrapper which maps a one-dimensional ndarray's buffer, length, stride, and offset into the corresponding strided kernel in [`@stdlib/stats/strided/meankbn`][@stdlib/stats/strided/meankbn].
43
+
44
+
</section>
45
+
46
+
<!-- /.intro -->
47
+
48
+
<sectionclass="usage">
4
49
5
50
## Usage
6
51
@@ -12,20 +57,46 @@ var meankbn = require( '@stdlib/stats/base/ndarray/meankbn' );
12
57
var buf =newFloat64Array( [ 1.0, 3.0, 4.0, 2.0 ] );
13
58
var x =newndarray( 'float64', buf, [ buf.length ], [ 1 ], 0, 'row-major' );
14
59
15
-
// ndarray variants accept an arraylike of ndarrays:
60
+
// ndarray variants accept an array-like of ndarrays:
16
61
var v =meankbn( [ x ] );
17
62
// returns 2.5
18
63
```
19
64
65
+
#### meankbn( arrays )
66
+
67
+
Computes the [arithmetic mean][arithmetic-mean] of a one-dimensional ndarray using the improved Kahan-Babuska algorithm.
68
+
69
+
The function has the following parameters:
70
+
71
+
-**arrays**: array-like object containing a single input ndarray.
72
+
73
+
**Returns**: arithmetic mean as a `number`.
74
+
75
+
</section>
76
+
77
+
<!-- /.usage -->
78
+
79
+
<sectionclass="notes">
80
+
20
81
## Notes
21
82
22
-
- If provided an empty vector, the function returns `NaN`.
23
-
- Supports non-unit and negative strides and non-zero offsets.
24
-
- Thin wrapper around `@stdlib/stats/strided/meankbn`.
83
+
- If provided an empty ndarray, the function returns `NaN`.
84
+
- The wrapper supports non-unit and negative strides and non-zero offsets.
85
+
- This package is a thin ndarray wrapper around [`@stdlib/stats/strided/meankbn`][@stdlib/stats/strided/meankbn]. Accuracy benefits come from compensated summation in the strided core.
86
+
87
+
</section>
88
+
89
+
<!-- /.notes -->
90
+
91
+
<sectionclass="examples">
25
92
26
93
## Examples
27
94
95
+
<!-- eslint-disable no-console -->
96
+
28
97
```javascript
98
+
'use strict';
99
+
29
100
var ndarray =require( '@stdlib/ndarray/base/ctor' );
var meankbn =require( '@stdlib/stats/base/ndarray/meankbn' );
@@ -36,7 +107,31 @@ var x = new ndarray( 'float64', buf, [ buf.length ], [ 1 ], 0, 'row-major' );
36
107
console.log( meankbn( [ x ] ) );
37
108
```
38
109
110
+
</section>
111
+
112
+
<!-- /.examples -->
113
+
114
+
<sectionclass="related">
115
+
116
+
* * *
117
+
39
118
## See Also
40
119
41
-
-`@stdlib/stats/base/ndarray/mean`
42
-
-`@stdlib/stats/strided/meankbn`
120
+
- <spanclass="package-name">[`@stdlib/stats/base/ndarray/mean`][@stdlib/stats/base/ndarray/mean]</span><spanclass="delimiter">: </span><spanclass="description">compute the arithmetic mean of a one-dimensional ndarray.</span>
121
+
- <spanclass="package-name">[`@stdlib/stats/strided/meankbn`][@stdlib/stats/strided/meankbn]</span><spanclass="delimiter">: </span><spanclass="description">compute the arithmetic mean using the improved Kahan-Babuska algorithm for strided arrays.</span>
0 commit comments