Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including array-means with all npm packages installed. Try it out:

var arrayMeans = require("array-means")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

array-means v1.6.1

Calculates various averages of an array

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

AlgorithmOperations per secondToleranceNumber of runs
arithmetic57,677,242 ops/sec±0.09%92 runs sampled
quadratic31,527,477 ops/sec±0.04%96 runs sampled
harmonic107,957,742 ops/sec±0.39%95 runs sampled
geometric122,245,766 ops/sec±0.22%95 runs sampled
cubic106,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.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free