Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

incrnanmin

Compute a minimum value incrementally, ignoring NaN values.

Usage

var incrnanmin = require( '@stdlib/stats/incr/nanmin' );

incrnanmin()

Returns an accumulator function which incrementally computes a minimum value, ignoring NaN values.

var accumulator = incrnanmin();

accumulator( [x] )

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

Notes

  • 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 returns null.

Examples

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() );