Calculate the mid-range of an array.
The mid-range is defined as the arithmetic mean of the maximum and minimum values in a data set. The measure is the midpoint of the range and a measure of central tendency.
var midrange = require( '@stdlib/stats/array/midrange' );Computes the mid-range of an array.
var x = [ 1.0, -2.0, 2.0 ];
var v = midrange( x );
// returns 0.0The function has the following parameters:
- x: input array.
- 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).
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var midrange = require( '@stdlib/stats/array/midrange' );
var x = discreteUniform( 10, -50, 50, {
'dtype': 'float64'
});
console.log( x );
var v = midrange( x );
console.log( v );