Skip to content

Commit f5dd32c

Browse files
chore: refractor lognormal/cdf benchmark.js and restore negative-binomial
--- 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: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - 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: na ---
1 parent 98a742d commit f5dd32c

File tree

2 files changed

+90
-5
lines changed

2 files changed

+90
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/base/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var EPS = require( '@stdlib/constants/float64/eps' );
2727
var pkg = require( './../package.json' ).name;
@@ -39,9 +39,9 @@ bench( pkg, function benchmark( b ) {
3939

4040
b.tic();
4141
for ( i = 0; i < b.iterations; i++ ) {
42-
x = ( randu()*100.0 ) - 100;
43-
mu = ( randu()*100.0 ) - 50.0;
44-
sigma = ( randu()*20.0 ) + EPS;
42+
x = uniform( -100.0, 100.0 );
43+
mu = uniform( -50.0, 50.0 );
44+
sigma = uniform( EPS, 20.0 );
4545
y = cdf( x, mu, sigma );
4646
if ( isnan( y ) ) {
4747
b.fail( 'should not return NaN' );
@@ -69,7 +69,7 @@ bench( pkg+':factory', function benchmark( b ) {
6969

7070
b.tic();
7171
for ( i = 0; i < b.iterations; i++ ) {
72-
x = randu() * 50.0;
72+
x = uniform( 0.0, 50.0 );
7373
y = mycdf( x );
7474
if ( isnan( y ) ) {
7575
b.fail( 'should not return NaN' );
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var ceil = require( '@stdlib/math/base/special/ceil' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var randu = require( '@stdlib/random/base/randu' );
27+
var EPS = require( '@stdlib/constants/float64/eps' );
28+
var pkg = require( './../package.json' ).name;
29+
var cdf = require( './../lib' );
30+
31+
32+
// MAIN //
33+
34+
bench( pkg, function benchmark( b ) {
35+
var r;
36+
var p;
37+
var x;
38+
var y;
39+
var i;
40+
41+
b.tic();
42+
for ( i = 0; i < b.iterations; i++ ) {
43+
x = randu()*100.0;
44+
r = ceil( randu()*100.0 );
45+
p = ( randu()*1.0 ) + EPS;
46+
y = cdf( x, r, p );
47+
if ( isnan( y ) ) {
48+
b.fail( 'should not return NaN' );
49+
}
50+
}
51+
b.toc();
52+
if ( isnan( y ) ) {
53+
b.fail( 'should not return NaN' );
54+
}
55+
b.pass( 'benchmark finished' );
56+
b.end();
57+
});
58+
59+
bench( pkg+':factory', function benchmark( b ) {
60+
var mycdf;
61+
var r;
62+
var p;
63+
var x;
64+
var y;
65+
var i;
66+
67+
r = 80;
68+
p = 0.4;
69+
mycdf = cdf.factory( r, p );
70+
71+
b.tic();
72+
for ( i = 0; i < b.iterations; i++ ) {
73+
x = ( randu()*100 );
74+
y = mycdf( x );
75+
if ( isnan( y ) ) {
76+
b.fail( 'should not return NaN' );
77+
}
78+
}
79+
b.toc();
80+
if ( isnan( y ) ) {
81+
b.fail( 'should not return NaN' );
82+
}
83+
b.pass( 'benchmark finished' );
84+
b.end();
85+
});

0 commit comments

Comments
 (0)