Skip to content

Commit 40aae66

Browse files
committed
refactor: random number generation in JS benchmarks for stats/base/dists/bernoulli
--- 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: na - 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: passed - 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: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests 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: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 9aaeaaa commit 40aae66

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/node_modules/@stdlib/stats/base/dists/bernoulli/cdf/benchmark/benchmark.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2627
var pkg = require( './../package.json' ).name;
2728
var cdf = require( './../lib' );
@@ -37,7 +38,7 @@ bench( pkg, function benchmark( b ) {
3738

3839
b.tic();
3940
for ( i = 0; i < b.iterations; i++ ) {
40-
x = ( randu()*3.0 ) - 1.0;
41+
x = uniform( -1.0, 2.0 );
4142
p = randu();
4243
y = cdf( x, p );
4344
if ( isnan( y ) ) {
@@ -64,7 +65,7 @@ bench( pkg+':factory', function benchmark( b ) {
6465

6566
b.tic();
6667
for ( i = 0; i < b.iterations; i++ ) {
67-
x = ( randu()*3.0 ) - 1.0;
68+
x = uniform( -1.0, 2.0 );
6869
y = mycdf( x );
6970
if ( isnan( y ) ) {
7071
b.fail( 'should not return NaN' );

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mean/benchmark/benchmark.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var Float64Array = require( '@stdlib/array/float64' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var EPS = require( '@stdlib/constants/float64/eps' );
2828
var pkg = require( './../package.json' ).name;
@@ -40,7 +40,7 @@ bench( pkg, function benchmark( b ) {
4040
len = 100;
4141
p = new Float64Array( len );
4242
for ( i = 0; i < len; i++ ) {
43-
p[ i ] = ( randu()*1.0 ) + EPS;
43+
p[ i ] = uniform( EPS, EPS + 1.0 );
4444
}
4545

4646
b.tic();

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mean/benchmark/benchmark.native.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
26-
var randu = require( '@stdlib/random/base/randu' );
26+
var uniform = require( '@stdlib/random/base/uniform' );
2727
var EPS = require( '@stdlib/constants/float64/eps' );
2828
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2929
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -49,7 +49,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4949
len = 100;
5050
p = new Float64Array( len );
5151
for ( i = 0; i < len; i++ ) {
52-
p[ i ] = ( randu()*1.0 ) + EPS;
52+
p[ i ] = uniform( EPS, EPS + 1.0 );
5353
}
5454

5555
b.tic();

0 commit comments

Comments
 (0)