File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
lib/node_modules/@stdlib/stats/incr/nanprod/examples Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 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' ) ;
2322var incrnanprod = require ( './../lib' ) ;
2423
2524var accumulator ;
@@ -33,7 +32,11 @@ accumulator = incrnanprod();
3332// For each simulated value, update the product...
3433console . log ( '\nValue\tProduct\n' ) ;
3534for ( 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}
You can’t perform that action at this time.
0 commit comments