Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

meankbn2

Calculate the arithmetic mean of an array using a second-order iterative Kahan–Babuška algorithm.

Usage

var meankbn2 = require( '@stdlib/stats/array/meankbn2' );

meankbn2( x )

Computes the arithmetic mean of an array using a second-order iterative Kahan–Babuška algorithm.

var x = [ 1.0, -2.0, 2.0 ];

var v = meankbn2( x );
// returns ~0.3333

The 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 meankbn2 = require( '@stdlib/stats/array/meankbn2' );

var x = discreteUniform( 10, -50, 50, {
    'dtype': 'float64'
});
console.log( x );

var v = meankbn2( x );
console.log( v );