Skip to content

Commit a76b231

Browse files
committed
docs: update examples to avoid explicit for loops
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent b93bbb1 commit a76b231

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

lib/node_modules/@stdlib/stats/base/dists/arcsine/cdf/README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,18 @@ y = mycdf( 8.0 );
115115
<!-- eslint no-undef: "error" -->
116116

117117
```javascript
118-
var randu = require( '@stdlib/random/base/randu' );
118+
var uniform = require( '@stdlib/random/array/uniform' );
119+
var logEachMap = require( '@stdlib/console/log-each-map' );
119120
var cdf = require( '@stdlib/stats/base/dists/arcsine/cdf' );
120121

121-
var a;
122-
var b;
123-
var x;
124-
var y;
125-
var i;
126-
127-
for ( i = 0; i < 25; i++ ) {
128-
x = ( randu()*20.0 ) - 10.0;
129-
a = ( randu()*20.0 ) - 20.0;
130-
b = a + ( randu()*40.0 );
131-
y = cdf( x, a, b );
132-
console.log( 'x: %d, a: %d, b: %d, F(x;a,b): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), y.toFixed( 4 ) );
133-
}
122+
var opts = {
123+
'dtype': 'float64'
124+
};
125+
var x = uniform( 25, -10.0, 10.0, opts );
126+
var a = uniform( x.length, -20.0, 0.0, opts );
127+
var b = uniform( x.length, 0.0, 40.0, opts );
128+
129+
logEachMap( 'x: %0.4f, a: %0.4f, b: %0.4f, F(x;a,b): %0.4f', x, a, b, cdf );
134130
```
135131

136132
</section>

lib/node_modules/@stdlib/stats/base/dists/arcsine/cdf/examples/index.js

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

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var cdf = require( './../lib' );
2324

24-
var a;
25-
var b;
26-
var x;
27-
var y;
28-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = uniform( 25, -10.0, 10.0, opts );
29+
var a = uniform( x.length, -20.0, 0.0, opts );
30+
var b = uniform( x.length, 0.0, 40.0, opts );
2931

30-
for ( i = 0; i < 25; i++ ) {
31-
x = ( randu()*20.0 ) - 10.0;
32-
a = ( randu()*20.0 ) - 20.0;
33-
b = a + ( randu()*40.0 );
34-
y = cdf( x, a, b );
35-
console.log( 'x: %d, a: %d, b: %d, F(x;a,b): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), y.toFixed( 4 ) );
36-
}
32+
logEachMap( 'x: %0.4f, a: %0.4f, b: %0.4f, F(x;a,b): %0.4f', x, a, b, cdf );

0 commit comments

Comments
 (0)