Skip to content

Commit a914822

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

File tree

1 file changed

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

1 file changed

+4
-8
lines changed

lib/node_modules/@stdlib/stats/incr/nanmape/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 incrnanmape = require( './../lib' );
2324

2425
var accumulator;
@@ -33,13 +34,8 @@ accumulator = incrnanmape();
3334
// For each simulated datum, update the mean absolute percentage error...
3435
console.log( '\nValue\tValue\tMAPE\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
err = accumulator( v1, v2 );
4440
console.log( '%d\t%d\t%d', v1.toFixed( 3 ), v2.toFixed( 3 ), ( err === null ) ? NaN : err.toFixed( 3 ) );
4541
}

0 commit comments

Comments
 (0)