Skip to content

Commit 11e626c

Browse files
chore: updating files
--- 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 ---
1 parent e347ae0 commit 11e626c

File tree

1 file changed

+85
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/negative-binomial/cdf/benchmark

1 file changed

+85
-0
lines changed
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)