Skip to content

Commit 0ac07a7

Browse files
committed
refactor: random number generation in examples
--- 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: na - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent b566479 commit 0ac07a7

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ y = cdf( 0.5, -1.0 );
100100

101101
#### cdf.factory( c )
102102

103-
Returns a `function` for evaluating the [CDF][cdf] of a [Bradford][bradford-distribution] distribution with shape parameter `c`.
103+
Returns a function for evaluating the [CDF][cdf] of a [Bradford][bradford-distribution] distribution with shape parameter `c`.
104104

105105
```javascript
106106
var myPDF = cdf.factory( 5.0 );
@@ -122,19 +122,17 @@ y = myPDF( 1.0 );
122122
<!-- eslint no-undef: "error" -->
123123

124124
```javascript
125-
var randu = require( '@stdlib/random/base/randu' );
125+
var uniform = require( '@stdlib/random/array/uniform' );
126126
var cdf = require( '@stdlib/stats/base/dists/bradford/cdf' );
127127

128-
var x;
129-
var c;
128+
var x = uniform( 10, 0.0, 1.0 );
129+
var c = uniform( 10, 0.1, 10.0 );
130+
130131
var y;
131132
var i;
132-
133-
for ( i = 0; i < 25; i++ ) {
134-
x = randu();
135-
c = ( randu()*10.0 );
136-
y = cdf( x, c );
137-
console.log( 'x: %d, c: %d, F(x;c): %d', x.toFixed( 4 ), c.toFixed( 4 ), y.toFixed( 4 ) );
133+
for ( i = 0; i < x.length; i++ ) {
134+
y = cdf( x[ i ], c[ i ] );
135+
console.log( 'x: %d, c: %d, F(x;c): %d', x[ i ].toFixed( 4 ), c[ i ].toFixed( 4 ), y.toFixed( 4 ) );
138136
}
139137
```
140138

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

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

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
2222
var cdf = require( './../lib' );
2323

24-
var x;
25-
var c;
24+
var x = uniform( 10, 0.0, 1.0 );
25+
var c = uniform( 10, 0.1, 10.0 );
26+
2627
var y;
2728
var i;
28-
29-
for ( i = 0; i < 25; i++ ) {
30-
x = randu();
31-
c = ( randu()*10.0 );
32-
y = cdf( x, c );
33-
console.log( 'x: %d, c: %d, F(x;c): %d', x.toFixed( 4 ), c.toFixed( 4 ), y.toFixed( 4 ) );
29+
for ( i = 0; i < x.length; i++ ) {
30+
y = cdf( x[ i ], c[ i ] );
31+
console.log( 'x: %d, c: %d, F(x;c): %d', x[ i ].toFixed( 4 ), c[ i ].toFixed( 4 ), y.toFixed( 4 ) );
3432
}

0 commit comments

Comments
 (0)