For Node.js run the following command:
npm i array-meansFor Yarn run the following command:
yarn add array-meansDownload the latest version of array-means here.
const {
arithmetic,
cubic,
geometric,
harmonic,
quadratic,
median,
} = require("array-means");Wikipedia article of Arithmetic mean
var amean = arithmetic([10, 25, 50]);
// amean => 28.333333333333332Wikipedia article of Quadratic mean
var qmean = quadratic([10, 25, 50]);
// qmean => 32.78719262151Wikipedia article of Harmonic mean
var hmean = harmonic([10, 25, 50]);
// hmean => 18.75Wikipedia article of Geometric mean
var gmean = geometric([10, 25, 50]);
// gmean => 23.20794417Wikipedia article of Cubic mean
var cmean = cubic([10, 25, 50]);
// cmean => 36.14150411var medianResult = median([10, 25, 50]);
// medianResult => 25| Algorithm | Operations per second | Tolerance |
|---|---|---|
| arithmetic | 90,273,949 ops/sec | ±0.40% |
| quadratic | 45,955,194 ops/sec | ±1.35% |
| harmonic | 142,704,156 ops/sec | ±0.33% |
| geometric | 116,823,047 ops/sec | ±0.20% |
| cubic | 786,168 ops/sec | ±0.12% |
| median | 3,392,087 ops/sec | ±0.21% |
Tested on an AMD Ryzen 7 5800X using Node.js v16.13.2 on Windows 10 (21H1)
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see here for more details.