Skip to content

Commit f4a1daa

Browse files
committed
Auto-generated commit
1 parent 7958b0a commit f4a1daa

File tree

4 files changed

+20
-26
lines changed

4 files changed

+20
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This release closes the following issue:
3434

3535
<details>
3636

37+
- [`a5e0667`](https://github.com/stdlib-js/stdlib/commit/a5e0667c308881e101549d77c6d8573e3b632c67) - **docs:** replace manual `for` loop in examples [(#6849)](https://github.com/stdlib-js/stdlib/pull/6849) _(by Harsh, Athan Reines)_
3738
- [`c1acd4b`](https://github.com/stdlib-js/stdlib/commit/c1acd4bf3ed08b40d6d4e93ee245f03c9eef8472) - **bench:** update random value generation [(#6858)](https://github.com/stdlib-js/stdlib/pull/6858) _(by Harsh, Athan Reines)_
3839
- [`a1e230f`](https://github.com/stdlib-js/stdlib/commit/a1e230f29297caa89880e9c194c615a0400fb7bc) - **chore:** clean up cppcheck-suppress comments _(by Karan Anand)_
3940
- [`d53a818`](https://github.com/stdlib-js/stdlib/commit/d53a8184c029c3df7c45a7a1a2da9ff90b4f883e) - **docs:** fix errors in the structure of READMEs in `stats/base/*` [(#5138)](https://github.com/stdlib-js/stdlib/pull/5138) _(by Aayush Khanna)_

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,18 @@ v = variance( 20, 1.5 );
153153
<!-- eslint no-undef: "error" -->
154154

155155
```javascript
156-
var randu = require( '@stdlib/random-base-randu' );
157-
var round = require( '@stdlib/math-base-special-round' );
156+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
157+
var uniform = require( '@stdlib/random-array-uniform' );
158+
var logEachMap = require( '@stdlib/console-log-each-map' );
158159
var variance = require( '@stdlib/stats-base-dists-binomial-variance' );
159160

160-
var v;
161-
var i;
162-
var n;
163-
var p;
161+
var opts = {
162+
'dtype': 'float64'
163+
};
164+
var n = discreteUniform( 10, 0, 100, opts );
165+
var p = uniform( 10, 0.0, 1.0, opts );
164166

165-
for ( i = 0; i < 10; i++ ) {
166-
n = round( randu() * 100.0 );
167-
p = randu();
168-
v = variance( n, p );
169-
console.log( 'n: %d, p: %d, Var(X;n,p): %d', n, p.toFixed( 4 ), v.toFixed( 4 ) );
170-
}
167+
logEachMap( 'n: %0.4f, p: %0.4f, Var(X;n,p): %0.4f', n, p, variance );
171168
```
172169

173170
</section>

examples/index.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,15 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random-base-randu' );
22-
var round = require( '@stdlib/math-base-special-round' );
21+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
22+
var uniform = require( '@stdlib/random-array-uniform' );
23+
var logEachMap = require( '@stdlib/console-log-each-map' );
2324
var variance = require( './../lib' );
2425

25-
var v;
26-
var i;
27-
var n;
28-
var p;
26+
var opts = {
27+
'dtype': 'float64'
28+
};
29+
var n = discreteUniform( 10, 0, 100, opts );
30+
var p = uniform( 10, 0.0, 1.0, opts );
2931

30-
for ( i = 0; i < 10; i++ ) {
31-
n = round( randu() * 100.0 );
32-
p = randu();
33-
v = variance( n, p );
34-
console.log( 'n: %d, p: %d, Var(X;n,p): %d', n, p.toFixed( 4 ), v.toFixed( 4 ) );
35-
}
32+
logEachMap( 'n: %0.4f, p: %0.4f, Var(X;n,p): %0.4f', n, p, variance );

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@
4747
"@stdlib/utils-library-manifest": "^0.2.2"
4848
},
4949
"devDependencies": {
50+
"@stdlib/console-log-each-map": "github:stdlib-js/console-log-each-map#main",
5051
"@stdlib/constants-float64-eps": "^0.2.2",
5152
"@stdlib/constants-float64-ninf": "^0.2.2",
5253
"@stdlib/math-base-special-abs": "^0.2.2",
5354
"@stdlib/math-base-special-ceil": "^0.2.2",
54-
"@stdlib/math-base-special-round": "^0.3.0",
5555
"@stdlib/random-array-discrete-uniform": "^0.2.1",
5656
"@stdlib/random-array-uniform": "^0.2.1",
57-
"@stdlib/random-base-randu": "^0.2.1",
5857
"@stdlib/utils-try-require": "^0.2.2",
5958
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
6059
"istanbul": "^0.4.1",

0 commit comments

Comments
 (0)