Calculate the maximum value of an array.
var max = require( '@stdlib/stats/array/max' );
Computes the maximum value of an array.
var x = [ 1.0, -2.0, 2.0 ];
var v = max( x );
// returns 2.0
The 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 max = require( '@stdlib/stats/array/max' );
var x = discreteUniform( 10, -50, 50, {
'dtype': 'float64'
});
console.log( x );
var v = max( x );
console.log( v );