Skip to content

Commit bb34fc5

Browse files
authored
update index.js
Signed-off-by: Harsh <[email protected]>
1 parent 025f7a5 commit bb34fc5

File tree

1 file changed

+4
-8
lines changed
  • lib/node_modules/@stdlib/stats/incr/nanrss/examples

1 file changed

+4
-8
lines changed

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

Lines changed: 4 additions & 8 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 incrnanrss = require( './../lib' );
2324

2425
var accumulator;
@@ -33,13 +34,8 @@ accumulator = incrnanrss();
3334
// For each simulated datum, update the residual sum of squares...
3435
console.log( '\nValue\tValue\tRSS\n' );
3536
for ( i = 0; i < 100; i++ ) {
36-
if ( randu() < 0.2 ) {
37-
v1 = NaN;
38-
v2 = NaN;
39-
} else {
40-
v1 = ( randu()*100.0 ) - 50.0;
41-
v2 = ( randu()*100.0 ) - 50.0;
42-
}
37+
v1 = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 );
38+
v2 = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 );
4339
rss = accumulator( v1, v2 );
4440
console.log( '%d\t%d\t%d', v1.toFixed( 3 ), v2.toFixed( 3 ), ( rss === null ) ? NaN : rss.toFixed( 3 ) );
4541
}

0 commit comments

Comments
 (0)