Skip to content

Commit f076764

Browse files
committed
exanmpe
1 parent 3f89e02 commit f076764

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

lib/node_modules/@stdlib/stats/incr/nanprod/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type accumulator = ( x?: number ) => number | null;
3939
* @returns accumulator function
4040
*
4141
* @example
42-
* var accumulator = incrprod();
42+
* var accumulator = incrnanprod();
4343
*
4444
* var v = accumulator();
4545
* // returns null

lib/node_modules/@stdlib/stats/incr/nanprod/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 uniform = require( '@stdlib/random/base/uniform' );
22+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
2223
var incrnanprod = require( './../lib' );
2324

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

0 commit comments

Comments
 (0)