Skip to content

Commit 272793c

Browse files
committed
refactor random number generation
--- 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: 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 96afef0 commit 272793c

File tree

3 files changed

+101
-94
lines changed

3 files changed

+101
-94
lines changed

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

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

2323
var bench = require( '@stdlib/bench' );
2424
var Float64Array = require( '@stdlib/array/float64' );
25-
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
26-
var uniform = require( '@stdlib/random/array/uniform' );
25+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
26+
var uniform = require( '@stdlib/random/base/uniform' );
2727
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2828
var pkg = require( './../package.json' ).name;
2929
var cdf = require( './../lib' );
@@ -42,13 +42,13 @@ bench( pkg, function benchmark( b ) {
4242
x = new Float64Array( len );
4343
lambda = new Float64Array( len );
4444
for ( i = 0; i < len; i++ ) {
45-
x[i] = (discreteUniform(0, 40) * 20.0) - 10.0;
46-
lambda[i] = (uniform(0, 40) * 20.0) + 1.0;
45+
x[i] = discreteUniform(0, 40);
46+
lambda[i] = uniform(1, 10);
4747
}
4848

4949
b.tic();
5050
for ( i = 0; i < b.iterations; i++ ) {
51-
y = cdf( x[ i % x.length ], lambda[ i % lambda.length ] );
51+
y = cdf( x[ i % len ], lambda[ i % len ] );
5252
if ( isnan( y ) ) {
5353
b.fail( 'should not return NaN' );
5454
}
@@ -62,17 +62,24 @@ bench( pkg, function benchmark( b ) {
6262
});
6363

6464
bench( pkg+':factory', function benchmark( b ) {
65+
var lambda;
6566
var mycdf;
67+
var len;
6668
var x;
6769
var y;
6870
var i;
6971

70-
x = discreteUniform( 100, 0, 40 );
71-
mycdf = cdf.factory( 0.3 );
72+
len = 100;
73+
lambda = uniform(1, 10);
74+
mycdf = cdf.factory( lambda );
75+
x = new Float64Array( len );
76+
for ( i = 0; i < len; i++ ) {
77+
x[ i ] = discreteUniform( 0.0, 40.0 );
78+
}
7279

7380
b.tic();
7481
for ( i = 0; i < b.iterations; i++ ) {
75-
y = mycdf( x[ i % x.length ] );
82+
y = mycdf( x[ i % len ] );
7683
if ( isnan( y ) ) {
7784
b.fail( 'should not return NaN' );
7885
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
26-
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
27-
var uniform = require( '@stdlib/random/array/uniform' );
26+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
27+
var uniform = require( '@stdlib/random/base/uniform' );
2828
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2929
var tryRequire = require( '@stdlib/utils/try-require' );
3030
var pkg = require( './../package.json' ).name;
@@ -51,8 +51,8 @@ bench( pkg+'::native', opts, function benchmark( b ) {
5151
x = new Float64Array( len );
5252
lambda = new Float64Array( len );
5353
for ( i = 0; i < len; i++ ) {
54-
x[i] = (discreteUniform(0, 40) * 20.0) - 10.0;
55-
lambda[i] = (uniform(0, 40) * 20.0) + 1.0;
54+
x[i] = discreteUniform(0, 40);
55+
lambda[i] = uniform(1, 10);
5656
}
5757

5858
b.tic();
Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
11
{
2-
"options": {
3-
"task": "build",
4-
"wasm": false
2+
"options": {
3+
"task": "build",
4+
"wasm": false
5+
},
6+
"fields": [
7+
{
8+
"field": "src",
9+
"resolve": true,
10+
"relative": true
11+
},
12+
{
13+
"field": "include",
14+
"resolve": true,
15+
"relative": true
16+
},
17+
{
18+
"field": "libraries",
19+
"resolve": false,
20+
"relative": false
521
},
6-
"fields": [
7-
{
8-
"field": "src",
9-
"resolve": true,
10-
"relative": true
11-
},
12-
{
13-
"field": "include",
14-
"resolve": true,
15-
"relative": true
16-
},
17-
{
18-
"field": "libraries",
19-
"resolve": false,
20-
"relative": false
21-
},
22-
{
23-
"field": "libpath",
24-
"resolve": true,
25-
"relative": false
26-
}
27-
],
22+
{
23+
"field": "libpath",
24+
"resolve": true,
25+
"relative": false
26+
}
27+
],
2828
"confs": [
29-
{
30-
"task": "build",
31-
"wasm": false,
32-
"src": [
33-
"./src/main.c"
34-
],
35-
"include": [
36-
"./include"
37-
],
38-
"libraries": [],
39-
"libpath": [],
40-
"dependencies": [
41-
"@stdlib/math/base/napi/binary",
42-
"@stdlib/math/base/assert/is-nan",
43-
"@stdlib/math/base/special/expm1",
44-
"@stdlib/math/base/special/floor",
45-
"@stdlib/constants/float64/pinf"
46-
]
47-
},
48-
{
49-
"task": "benchmark",
50-
"wasm": false,
51-
"src": [
52-
"./src/main.c"
53-
],
54-
"include": [
55-
"./include"
56-
],
57-
"libraries": [],
58-
"libpath": [],
59-
"dependencies": [
60-
"@stdlib/math/base/assert/is-nan",
61-
"@stdlib/math/base/special/expm1",
62-
"@stdlib/math/base/special/floor",
63-
"@stdlib/constants/float64/pinf"
64-
]
65-
},
66-
{
67-
"task": "examples",
68-
"wasm": false,
69-
"src": [
70-
"./src/main.c"
71-
],
72-
"include": [
73-
"./include"
74-
],
75-
"libraries": [],
76-
"libpath": [],
77-
"dependencies": [
78-
"@stdlib/math/base/assert/is-nan",
79-
"@stdlib/math/base/special/expm1",
80-
"@stdlib/math/base/special/floor",
81-
"@stdlib/constants/float64/pinf"
82-
]
83-
}
84-
]
85-
}
29+
{
30+
"task": "build",
31+
"wasm": false,
32+
"src": [
33+
"./src/main.c"
34+
],
35+
"include": [
36+
"./include"
37+
],
38+
"libraries": [],
39+
"libpath": [],
40+
"dependencies": [
41+
"@stdlib/math/base/napi/binary",
42+
"@stdlib/math/base/assert/is-nan",
43+
"@stdlib/math/base/special/expm1",
44+
"@stdlib/math/base/special/floor",
45+
"@stdlib/constants/float64/pinf"
46+
]
47+
},
48+
{
49+
"task": "benchmark",
50+
"wasm": false,
51+
"src": [
52+
"./src/main.c"
53+
],
54+
"include": [
55+
"./include"
56+
],
57+
"libraries": [],
58+
"libpath": [],
59+
"dependencies": [
60+
"@stdlib/math/base/assert/is-nan",
61+
"@stdlib/math/base/special/expm1",
62+
"@stdlib/math/base/special/floor",
63+
"@stdlib/constants/float64/pinf"
64+
]
65+
},
66+
{
67+
"task": "examples",
68+
"wasm": false,
69+
"src": [
70+
"./src/main.c"
71+
],
72+
"include": [
73+
"./include"
74+
],
75+
"libraries": [],
76+
"libpath": [],
77+
"dependencies": [
78+
"@stdlib/math/base/assert/is-nan",
79+
"@stdlib/math/base/special/expm1",
80+
"@stdlib/math/base/special/floor",
81+
"@stdlib/constants/float64/pinf"
82+
]
83+
}
84+
]
85+
}

0 commit comments

Comments
 (0)