Skip to content

Commit b229f9f

Browse files
authored
Update index.js
Signed-off-by: Harsh <[email protected]>
1 parent b65f2f0 commit b229f9f

File tree

1 file changed

+6
-10
lines changed
  • lib/node_modules/@stdlib/stats/incr/nanmpe/examples

1 file changed

+6
-10
lines changed

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

Lines changed: 6 additions & 10 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 incrnanmpe = require( './../lib' );
2324

2425
var accumulator;
@@ -33,14 +34,9 @@ accumulator = incrnanmpe();
3334
// For each simulated datum, update the mean percentage error...
3435
console.log( '\nValue\tValue\tPercent\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-
}
43-
err = accumulator( v1, v2 );
44-
console.log( '%d\t%d\t%d', v1.toFixed( 3 ), v2.toFixed( 3 ), ( err === null ) ? NaN : err.toFixed( 3 ) );
37+
v1 = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 );
38+
v2 = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 );
39+
err = accumulator( v1, v2 );
40+
console.log( '%d\t%d\t%d', v1.toFixed( 3 ), v2.toFixed( 3 ), ( err === null ) ? NaN : err.toFixed( 3 ) );
4541
}
4642
console.log( '\nFinal MPE: %d\n', accumulator() );

0 commit comments

Comments
 (0)