Skip to content

Commit 6dd57ac

Browse files
committed
docs: modernize PRNG usage and fix C parameter generation in kumaraswamy/cdf
--- 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: passed - 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: passed - 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: passed - task: lint_c_benchmarks status: passed - 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: na ---
1 parent 9f25646 commit 6dd57ac

File tree

6 files changed

+36
-35
lines changed

6 files changed

+36
-35
lines changed

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/cdf/README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ y = mycdf( 0.3 );
141141
<!-- eslint no-undef: "error" -->
142142

143143
```javascript
144-
var randu = require( '@stdlib/random/base/randu' );
144+
var uniform = require( '@stdlib/random/array/uniform' );
145145
var EPS = require( '@stdlib/constants/float64/eps' );
146146
var cdf = require( '@stdlib/stats/base/dists/kumaraswamy/cdf' );
147147

@@ -151,12 +151,13 @@ var x;
151151
var y;
152152
var i;
153153

154-
for ( i = 0; i < 10; i++ ) {
155-
x = randu();
156-
a = ( randu()*5.0 ) + EPS;
157-
b = ( randu()*5.0 ) + EPS;
158-
y = cdf( x, a, b );
159-
console.log( 'x: %d, a: %d, b: %d, F(x;a,b): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), y.toFixed( 4 ) );
154+
x = uniform( 10, 0.0, 1.0 );
155+
a = uniform( 10, EPS, 5.0 );
156+
b = uniform( 10, EPS, 5.0 );
157+
158+
for ( i = 0; i < x.length; i++ ) {
159+
y = cdf( x[ i ], a[ i ], b[ i ] );
160+
console.log( 'x: %d, a: %d, b: %d, F(x;a,b): %d', x[ i ].toFixed( 4 ), a[ i ].toFixed( 4 ), b[ i ].toFixed( 4 ), y.toFixed( 4 ) );
160161
}
161162
```
162163

@@ -229,6 +230,7 @@ double stdlib_base_dists_kumaraswamy_cdf( const double x, const double a, const
229230
230231
```c
231232
#include "stdlib/stats/base/dists/kumaraswamy/cdf.h"
233+
#include "stdlib/constants/float64/eps.h"
232234
#include <stdlib.h>
233235
#include <stdio.h>
234236
@@ -245,9 +247,9 @@ int main( void ) {
245247
int i;
246248
247249
for ( i = 0; i < 25; i++ ) {
248-
x = random_uniform( 0, 1.0 );
249-
a = random_uniform( 0, 5.0 );
250-
b = random_uniform( 0, 5.0 );
250+
x = random_uniform( 0.0, 1.0 );
251+
a = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
252+
b = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
251253
y = stdlib_base_dists_kumaraswamy_cdf( x, a, b );
252254
printf( "x: %lf, a: %lf, b: %lf, F(x;a,b): %lf\n", x, a, b, y );
253255
}

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

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

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var Float64Array = require( '@stdlib/array/float64' );
26-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var EPS = require( '@stdlib/constants/float64/eps' );
2928
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -49,14 +48,9 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4948
var i;
5049

5150
len = 100;
52-
x = new Float64Array( len );
53-
a = new Float64Array( len );
54-
s = new Float64Array( len );
55-
for ( i = 0; i < len; i++ ) {
56-
x[ i ] = randu();
57-
a[ i ] = ( randu()*5.0 ) + EPS;
58-
s[ i ] = ( randu()*5.0 ) + EPS;
59-
}
51+
x = uniform( len, 0.0, 1.0 );
52+
a = uniform( len, EPS, 5.0 );
53+
s = uniform( len, EPS, 5.0 );
6054

6155
b.tic();
6256
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/cdf/benchmark/c/benchmark.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/kumaraswamy/cdf.h"
20+
#include "stdlib/constants/float64/eps.h"
2021
#include <stdlib.h>
2122
#include <stdio.h>
2223
#include <math.h>
@@ -101,9 +102,9 @@ static double benchmark( void ) {
101102
int i;
102103

103104
for ( i = 0; i < 100; i++ ) {
104-
x[ i ] = random_uniform( -10.0, 10.0 );
105-
a[ i ] = random_uniform( 0, 10.0 );
106-
b[ i ] = random_uniform( a[ i ], a[ i ]+40.0 );
105+
x[ i ] = random_uniform( 0.0, 1.0 );
106+
a[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
107+
b[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
107108
}
108109

109110
t = tic();

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/cdf/examples/c/example.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/kumaraswamy/cdf.h"
20+
#include "stdlib/constants/float64/eps.h"
2021
#include <stdlib.h>
2122
#include <stdio.h>
2223

@@ -33,9 +34,9 @@ int main( void ) {
3334
int i;
3435

3536
for ( i = 0; i < 25; i++ ) {
36-
x = random_uniform( 0, 1.0 );
37-
a = random_uniform( 0, 5.0 );
38-
b = random_uniform( 0, 5.0 );
37+
x = random_uniform( 0.0, 1.0 );
38+
a = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
39+
b = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
3940
y = stdlib_base_dists_kumaraswamy_cdf( x, a, b );
4041
printf( "x: %lf, a: %lf, b: %lf, F(x;a,b): %lf\n", x, a, b, y );
4142
}

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/cdf/examples/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
2222
var EPS = require( '@stdlib/constants/float64/eps' );
2323
var cdf = require( './../lib' );
2424

@@ -28,10 +28,11 @@ var x;
2828
var y;
2929
var i;
3030

31-
for ( i = 0; i < 10; i++ ) {
32-
x = randu();
33-
a = ( randu()*5.0 ) + EPS;
34-
b = ( randu()*5.0 ) + EPS;
35-
y = cdf( x, a, b );
36-
console.log( 'x: %d, a: %d, b: %d, F(x;a,b): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), y.toFixed( 4 ) );
31+
x = uniform( 10, 0.0, 1.0 );
32+
a = uniform( 10, EPS, 5.0 );
33+
b = uniform( 10, EPS, 5.0 );
34+
35+
for ( i = 0; i < x.length; i++ ) {
36+
y = cdf( x[ i ], a[ i ], b[ i ] );
37+
console.log( 'x: %d, a: %d, b: %d, F(x;a,b): %d', x[ i ].toFixed( 4 ), a[ i ].toFixed( 4 ), b[ i ].toFixed( 4 ), y.toFixed( 4 ) );
3738
}

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/cdf/manifest.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"libpath": [],
5757
"dependencies": [
5858
"@stdlib/math/base/assert/is-nan",
59-
"@stdlib/math/base/special/pow"
59+
"@stdlib/math/base/special/pow",
60+
"@stdlib/constants/float64/eps"
6061
]
6162
},
6263
{
@@ -72,7 +73,8 @@
7273
"libpath": [],
7374
"dependencies": [
7475
"@stdlib/math/base/assert/is-nan",
75-
"@stdlib/math/base/special/pow"
76+
"@stdlib/math/base/special/pow",
77+
"@stdlib/constants/float64/eps"
7678
]
7779
}
7880
]

0 commit comments

Comments
 (0)