Compute a minimum value incrementally, ignoring
NaNvalues.
var incrnanmin = require( '@stdlib/stats/incr/nanmin' );Returns an accumulator function which incrementally computes a minimum value, ignoring NaN values.
var accumulator = incrnanmin();If provided an input value x, the accumulator function returns an updated minimum value. If not provided an input value x, the accumulator function returns the current minimum value.
var accumulator = incrnanmin();
var min = accumulator( 2.0 );
// returns 2.0
min = accumulator( 1.0 );
// returns 1.0
min = accumulator( NaN );
// returns 1.0
min = accumulator( 3.0 );
// returns 1.0
min = accumulator();
// returns 1.0- Input values are not type checked. If non-numeric inputs are possible, you are advised to type check and handle accordingly before passing the value to the accumulator function.
- If all provided values are
NaN, the accumulator returnsnull.
var bernoulli = require( '@stdlib/random/base/bernoulli' );
var uniform = require( '@stdlib/random/base/uniform' );
var incrnanmin = require( '@stdlib/stats/incr/nanmin' );
var accumulator;
var v;
var i;
// Initialize an accumulator:
accumulator = incrnanmin();
// For each simulated datum, update the min...
for ( i = 0; i < 100; i++ ) {
if ( bernoulli( 0.2 ) ) {
v = NaN;
} else {
v = uniform( 0.0, 100.0 );
}
accumulator( v );
}
console.log( accumulator() );