Skip to content

Commit 3f89e02

Browse files
committed
exanmpe
1 parent d291cde commit 3f89e02

File tree

1 file changed

+6
-3
lines changed
  • lib/node_modules/@stdlib/stats/incr/nanprod/examples

1 file changed

+6
-3
lines changed

lib/node_modules/@stdlib/stats/incr/nanprod/examples/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
'use strict';
2020

21-
var uniform = require( '@stdlib/random/base/uniform' );
22-
var bernoulli = require( '@stdlib/random/base/bernoulli' );
21+
var randu = require( '@stdlib/random/base/randu' );
2322
var incrnanprod = require( './../lib' );
2423

2524
var accumulator;
@@ -33,7 +32,11 @@ accumulator = incrnanprod();
3332
// For each simulated value, update the product...
3433
console.log( '\nValue\tProduct\n' );
3534
for ( i = 0; i < 100; i++ ) {
36-
v = ( bernoulli( 0.2 ) < 1 ) ? NaN : uniform( 0.0, 100.0 );
35+
if ( randu() < 0.2 ) {
36+
v = NaN;
37+
} else {
38+
v = randu() * 100.0;
39+
}
3740
prod = accumulator( v );
3841
console.log( '%d\t%d', v.toFixed( 4 ), ( prod === null ) ? NaN : prod.toFixed( 4 ) );
3942
}

0 commit comments

Comments
 (0)