@stdlib/stats-array-meanpn
v0.1.1
Published
Calculate the arithmetic mean of an array using a two-pass error correction algorithm.
Downloads
51
Readme
meanpn
Calculate the arithmetic mean of an array using a two-pass error correction algorithm.
Installation
npm install @stdlib/stats-array-meanpnUsage
var meanpn = require( '@stdlib/stats-array-meanpn' );meanpn( x )
Computes the arithmetic mean of an array using a two-pass error correction algorithm.
var x = [ 1.0, -2.0, 2.0 ];
var v = meanpn( x );
// returns ~0.3333The function has the following parameters:
- x: input array.
Notes
- If provided an empty array, the function returns
NaN. - The function supports array-like objects having getter and setter accessors for array element access (e.g.,
@stdlib/array-base/accessor).
Examples
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
var meanpn = require( '@stdlib/stats-array-meanpn' );
var x = discreteUniform( 10, -50, 50, {
'dtype': 'float64'
});
console.log( x );
var v = meanpn( x );
console.log( v );Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
