Skip to content
Calculates various averages of an array
JavaScript TypeScript
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
test
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
LICENSE
README.md
array-means.ts
package-lock.json
package.json
tsconfig.json

README.md

array-means

Calculates various averages of an array

Codacy Badge Build Status codecov npm bundle size (minified + gzip) npm GitHub issues GitHub closed issues GitHub

Installing

Node.js environment

npm i array-means --save

Browser environment

Download the latest version of array-means here.

Usage

Node.js environment

const arrayMeans = require("array-means");

var amean = arrayMeans.arithmetic([10, 25, 50]);
var amean = arrayMeans.a([10, 25, 50]);
// amean => 28.333333333333332

var qmean = arrayMeans.quadratic([10, 25, 50]);
var qmean = arrayMeans.q([10, 25, 50]);
// qmean => 32.78719262151

var hmean = arrayMeans.harmonic([10, 25, 50]);
var hmean = arrayMeans.h([10, 25, 50]);
// hmean => 18.75

var gmean = arrayMeans.geometric([10, 25, 50]);
var gmean = arrayMeans.g([10, 25, 50]);
// gmean => 23,20794417

var cmean = arrayMeans.cubic([10, 25, 50]);
var cmean = arrayMeans.c([10, 25, 50]);
// cmean => 36,14150411

Benchmark

Algorithm Operations per second Tolerance Number of runs
arithmetic 57,677,242 ops/sec ±0.09% 92 runs sampled
quadratic 31,527,477 ops/sec ±0.04% 96 runs sampled
harmonic 107,957,742 ops/sec ±0.39% 95 runs sampled
geometric 122,245,766 ops/sec ±0.22% 95 runs sampled
cubic 106,860,481 ops/sec ±0.44% 92 runs sampled

Tested with the benchmark suite inside the package on a PC with an Intel Core i7-4790K @ 4.40 GHz using Node.js v10.13.0.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the GPL-3.0 License - see here for more details.

You can’t perform that action at this time.