Skip to content

Commit 1b8777a

Browse files
committed
added the example
1 parent a97976b commit 1b8777a

File tree

1 file changed

+38
-0
lines changed
  • lib/node_modules/@stdlib/stats/incr/nanmmin/examples

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var randu = require( '@stdlib/random/base/randu' );
22+
var incrnanmmin = require( './../lib' );
23+
24+
var accumulator;
25+
var m;
26+
var v;
27+
var i;
28+
29+
// Initialize an accumulator:
30+
accumulator = incrnanmmin( 5 );
31+
32+
// For each simulated datum, update the moving minimum...
33+
console.log( '\nValue\tMin\n' );
34+
for ( i = 0; i < 100; i++ ) {
35+
v = ( randu() < 0.1 ) ? NaN : randu() * 100.0;
36+
m = accumulator( v );
37+
console.log( '%s\t%s', isnan( v ) ? 'NaN' : v.toFixed( 4 ), m !== null ? m.toFixed( 4 ) : 'null' );
38+
}

0 commit comments

Comments
 (0)