Skip to content

Latest commit

 

History

History
116 lines (71 loc) · 2.66 KB

File metadata and controls

116 lines (71 loc) · 2.66 KB

mskmax

Calculate the maximum value of an array according to a mask.

Usage

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

mskmax( x, mask )

Computes the maximum value of an array according to a mask.

var x = [ 1.0, -2.0, 4.0, 2.0 ];
var mask = [ 0, 0, 1, 0 ];

var v = mskmax( x, mask );
// returns 2.0

The function has the following parameters:

  • x: input array.
  • mask: mask array. If a mask array element is 0, the corresponding element in x is considered valid and included in computation. If a mask array element is 1, the corresponding element in x is considered invalid/missing and excluded from computation.

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 uniform = require( '@stdlib/random/array/uniform' );
var bernoulli = require( '@stdlib/random/array/bernoulli' );
var mskmax = require( '@stdlib/stats/array/mskmax' );

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

var mask = bernoulli( x.length, 0.2, {
    'dtype': 'uint8'
});
console.log( mask );

var v = mskmax( x, mask );
console.log( v );