Skip to content

Commit 29878a2

Browse files
authored
Update README.md to fit project conventions
Signed-off-by: Bureir AL <[email protected]>
1 parent c31588c commit 29878a2

File tree

1 file changed

+102
-7
lines changed
  • lib/node_modules/@stdlib/stats/base/ndarray/meankbn

1 file changed

+102
-7
lines changed
Lines changed: 102 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,51 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
121
# @stdlib/stats/base/ndarray/meankbn
222

3-
> Compute the arithmetic mean of a one-dimensional ndarray using the improved Kahan–Babuška algorithm.
23+
> Compute the [arithmetic mean][arithmetic-mean] of a one-dimensional ndarray using the improved Kahan-Babuska algorithm.
24+
25+
<section class="intro">
26+
27+
The [arithmetic mean][arithmetic-mean] is defined as
28+
29+
<!-- <equation class="equation" label="eq:arithmetic_mean" align="center" raw="\mu = \frac{1}{n} \sum_{i=0}^{n-1} x_i" alt="Equation for the arithmetic mean."> -->
30+
31+
```math
32+
\mu = \frac{1}{n} \sum_{i=0}^{n-1} x_i
33+
```
34+
35+
<!-- <div class="equation" align="center" data-raw-text="\mu = \frac{1}{n} \sum_{i=0}^{n-1} x_i" data-equation="eq:arithmetic_mean">
36+
<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+
<section class="usage">
449

550
## Usage
651

@@ -12,20 +57,46 @@ var meankbn = require( '@stdlib/stats/base/ndarray/meankbn' );
1257
var buf = new Float64Array( [ 1.0, 3.0, 4.0, 2.0 ] );
1358
var x = new ndarray( 'float64', buf, [ buf.length ], [ 1 ], 0, 'row-major' );
1459

15-
// ndarray variants accept an array like of ndarrays:
60+
// ndarray variants accept an array-like of ndarrays:
1661
var v = meankbn( [ x ] );
1762
// returns 2.5
1863
```
1964

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+
<section class="notes">
80+
2081
## Notes
2182

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+
<section class="examples">
2592

2693
## Examples
2794

95+
<!-- eslint-disable no-console -->
96+
2897
```javascript
98+
'use strict';
99+
29100
var ndarray = require( '@stdlib/ndarray/base/ctor' );
30101
var Float64Array = require( '@stdlib/array/float64' );
31102
var meankbn = require( '@stdlib/stats/base/ndarray/meankbn' );
@@ -36,7 +107,31 @@ var x = new ndarray( 'float64', buf, [ buf.length ], [ 1 ], 0, 'row-major' );
36107
console.log( meankbn( [ x ] ) );
37108
```
38109

110+
</section>
111+
112+
<!-- /.examples -->
113+
114+
<section class="related">
115+
116+
* * *
117+
39118
## See Also
40119

41-
- `@stdlib/stats/base/ndarray/mean`
42-
- `@stdlib/stats/strided/meankbn`
120+
- <span class="package-name">[`@stdlib/stats/base/ndarray/mean`][@stdlib/stats/base/ndarray/mean]</span><span class="delimiter">: </span><span class="description">compute the arithmetic mean of a one-dimensional ndarray.</span>
121+
- <span class="package-name">[`@stdlib/stats/strided/meankbn`][@stdlib/stats/strided/meankbn]</span><span class="delimiter">: </span><span class="description">compute the arithmetic mean using the improved Kahan-Babuska algorithm for strided arrays.</span>
122+
123+
</section>
124+
125+
<!-- /.related -->
126+
127+
<section class="links">
128+
129+
[arithmetic-mean]: https://en.wikipedia.org/wiki/Arithmetic_mean
130+
131+
[@stdlib/stats/base/ndarray/mean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/ndarray/mean
132+
133+
[@stdlib/stats/strided/meankbn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/meankbn
134+
135+
</section>
136+
137+
<!-- /.links -->

0 commit comments

Comments
 (0)