Skip to content

Commit

Permalink
refactor random number generation
Browse files Browse the repository at this point in the history
---
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
---
  • Loading branch information
yuvi-mittal committed Feb 2, 2025
1 parent 96afef0 commit 272793c
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var cdf = require( './../lib' );
Expand All @@ -42,13 +42,13 @@ bench( pkg, function benchmark( b ) {
x = new Float64Array( len );
lambda = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[i] = (discreteUniform(0, 40) * 20.0) - 10.0;
lambda[i] = (uniform(0, 40) * 20.0) + 1.0;
x[i] = discreteUniform(0, 40);
lambda[i] = uniform(1, 10);
}

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

bench( pkg+':factory', function benchmark( b ) {
var lambda;
var mycdf;
var len;
var x;
var y;
var i;

x = discreteUniform( 100, 0, 40 );
mycdf = cdf.factory( 0.3 );
len = 100;
lambda = uniform(1, 10);
mycdf = cdf.factory( lambda );
x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = discreteUniform( 0.0, 40.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = mycdf( x[ i % x.length ] );
y = mycdf( x[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -51,8 +51,8 @@ bench( pkg+'::native', opts, function benchmark( b ) {
x = new Float64Array( len );
lambda = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[i] = (discreteUniform(0, 40) * 20.0) - 10.0;
lambda[i] = (uniform(0, 40) * 20.0) + 1.0;
x[i] = discreteUniform(0, 40);
lambda[i] = uniform(1, 10);
}

b.tic();
Expand Down
164 changes: 82 additions & 82 deletions lib/node_modules/@stdlib/stats/base/dists/planck/cdf/manifest.json
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
{
"options": {
"task": "build",
"wasm": false
"options": {
"task": "build",
"wasm": false
},
"fields": [
{
"field": "src",
"resolve": true,
"relative": true
},
{
"field": "include",
"resolve": true,
"relative": true
},
{
"field": "libraries",
"resolve": false,
"relative": false
},
"fields": [
{
"field": "src",
"resolve": true,
"relative": true
},
{
"field": "include",
"resolve": true,
"relative": true
},
{
"field": "libraries",
"resolve": false,
"relative": false
},
{
"field": "libpath",
"resolve": true,
"relative": false
}
],
{
"field": "libpath",
"resolve": true,
"relative": false
}
],
"confs": [
{
"task": "build",
"wasm": false,
"src": [
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/napi/binary",
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/special/expm1",
"@stdlib/math/base/special/floor",
"@stdlib/constants/float64/pinf"
]
},
{
"task": "benchmark",
"wasm": false,
"src": [
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/special/expm1",
"@stdlib/math/base/special/floor",
"@stdlib/constants/float64/pinf"
]
},
{
"task": "examples",
"wasm": false,
"src": [
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/special/expm1",
"@stdlib/math/base/special/floor",
"@stdlib/constants/float64/pinf"
]
}
]
}
{
"task": "build",
"wasm": false,
"src": [
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/napi/binary",
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/special/expm1",
"@stdlib/math/base/special/floor",
"@stdlib/constants/float64/pinf"
]
},
{
"task": "benchmark",
"wasm": false,
"src": [
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/special/expm1",
"@stdlib/math/base/special/floor",
"@stdlib/constants/float64/pinf"
]
},
{
"task": "examples",
"wasm": false,
"src": [
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/special/expm1",
"@stdlib/math/base/special/floor",
"@stdlib/constants/float64/pinf"
]
}
]
}

0 comments on commit 272793c

Please sign in to comment.