Skip to content

Commit 837811f

Browse files
authored
update index.js
Signed-off-by: Harsh <[email protected]>
1 parent 3763920 commit 837811f

File tree

1 file changed

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

1 file changed

+3
-6
lines changed

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

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

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
22+
var uniform = require( '@stdlib/random/base/uniform' );
2223
var incrnanmsumabs = require( './../lib' );
2324

2425
var accumulator;
@@ -32,11 +33,7 @@ accumulator = incrnanmsumabs( 5 );
3233
// For each simulated datum, update the moving sum...
3334
console.log( '\nValue\tSum\n' );
3435
for ( i = 0; i < 100; i++ ) {
35-
if ( randu() < 0.2 ) {
36-
v = NaN;
37-
} else {
38-
v = ( randu()*100.0 ) - 50.0;
39-
}
36+
v = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 );
4037
sum = accumulator( v );
4138
console.log( '%d\t%d', v.toFixed( 3 ), ( sum === null ) ? NaN : sum.toFixed( 3 ) );
4239
}

0 commit comments

Comments
 (0)