Skip to content

Commit 35660ae

Browse files
committed
fix: update documentation and examples to use proper uniform distributions
--- 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: passed - 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 ---
1 parent ff81716 commit 35660ae

File tree

9 files changed

+42
-37
lines changed

9 files changed

+42
-37
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ y = mycdf( 7.0 );
136136
<!-- eslint no-undef: "error" -->
137137

138138
```javascript
139-
var randu = require( '@stdlib/random/base/randu' );
139+
var uniform = require( '@stdlib/random/base/uniform' );
140+
var EPS = require( '@stdlib/constants/float64/eps' );
140141
var cdf = require( '@stdlib/stats/base/dists/frechet/cdf' );
141142

142143
var alpha;
@@ -147,10 +148,10 @@ var y;
147148
var i;
148149

149150
for ( i = 0; i < 100; i++ ) {
150-
alpha = randu() * 10.0;
151-
x = randu() * 10.0;
152-
s = randu() * 10.0;
153-
m = randu() * 10.0;
151+
alpha = uniform( EPS, 5.0 );
152+
s = uniform( EPS, 5.0 );
153+
m = uniform( -2.0, 2.0 );
154+
x = uniform( m + 0.1, m + 10.0 );
154155
y = cdf( x, alpha, s, m );
155156
console.log( 'x: %d, α: %d, s: %d, m: %d, F(x;α,s,m): %d', x.toFixed( 4 ), alpha.toFixed( 4 ), s.toFixed( 4 ), m.toFixed( 4 ), y.toFixed( 4 ) );
156157
}
@@ -228,6 +229,7 @@ double stdlib_base_dists_frechet_cdf( const double x, const double alpha, const
228229
229230
```c
230231
#include "stdlib/stats/base/dists/frechet/cdf.h"
232+
#include "stdlib/constants/float64/eps.h"
231233
#include <stdlib.h>
232234
#include <stdio.h>
233235
@@ -245,10 +247,10 @@ int main( void ) {
245247
int i;
246248
247249
for ( i = 0; i < 10; i++ ) {
248-
x = random_uniform( 0.0, 10.0 );
249-
alpha = random_uniform( 0.0, 10.0 );
250-
s = random_uniform( 0.0, 10.0 );
251-
m = random_uniform( 0.0, 10.0 );
250+
alpha = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
251+
s = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
252+
m = random_uniform( -2.0, 2.0 );
253+
x = random_uniform( m + 0.1, m + 10.0 );
252254
y = stdlib_base_dists_frechet_cdf( x, alpha, s, m );
253255
printf( "x: %lf, alpha: %lf, s: %lf, m: %lf, F(x;alpha,s,m): %lf\n", x, alpha, s, m, y );
254256
}

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

Lines changed: 6 additions & 6 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 Float64Array = require( '@stdlib/array/float64' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var EPS = require( '@stdlib/constants/float64/eps' );
@@ -46,10 +46,10 @@ bench( pkg, function benchmark( b ) {
4646
s = new Float64Array( len );
4747
m = new Float64Array( len );
4848
for ( i = 0; i < len; i++ ) {
49-
x[ i ] = ( randu()*100.0 ) - 50.0;
50-
alpha[ i ] = ( randu()*20.0 ) + EPS;
51-
m[ i ] = ( randu()*60.0 ) - 20.0;
52-
s[ i ] = ( randu()*20.0 ) + EPS;
49+
alpha[ i ] = uniform( EPS, 5.0 );
50+
s[ i ] = uniform( EPS, 5.0 );
51+
m[ i ] = uniform( -2.0, 2.0 );
52+
x[ i ] = uniform( m[ i ] + 0.1, m[ i ] + 20.0 );
5353
}
5454
b.tic();
5555
for ( i = 0; i < b.iterations; i++ ) {
@@ -82,7 +82,7 @@ bench( pkg+':factory', function benchmark( b ) {
8282

8383
b.tic();
8484
for ( i = 0; i < b.iterations; i++ ) {
85-
x = randu() * 50.0;
85+
x = uniform( m + 0.1, m + 50.0 );
8686
y = mycdf( x );
8787
if ( isnan( y ) ) {
8888
b.fail( 'should not return NaN' );

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
26-
var randu = require( '@stdlib/random/base/randu' );
26+
var uniform = require( '@stdlib/random/base/uniform' );
2727
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2828
var tryRequire = require( '@stdlib/utils/try-require' );
2929
var EPS = require( '@stdlib/constants/float64/eps' );
@@ -55,10 +55,10 @@ bench( pkg+'::native', opts, function benchmark( b ) {
5555
s = new Float64Array( len );
5656
m = new Float64Array( len );
5757
for ( i = 0; i < len; i++ ) {
58-
x[ i ] = ( randu()*100.0 ) - 50.0;
59-
alpha[ i ] = ( randu()*20.0 ) + EPS;
60-
m[ i ] = ( randu()*60.0 ) - 20.0;
61-
s[ i ] = ( randu()*20.0 ) + EPS;
58+
alpha[ i ] = uniform( EPS, 5.0 );
59+
s[ i ] = uniform( EPS, 5.0 );
60+
m[ i ] = uniform( -2.0, 2.0 );
61+
x[ i ] = uniform( m[ i ] + 0.1, m[ i ] + 20.0 );
6262
}
6363
b.tic();
6464
for ( i = 0; i < b.iterations; i++ ) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ static double benchmark( void ) {
103103
int i;
104104

105105
for ( i = 0; i < 100; i++ ) {
106-
x[ i ] = random_uniform( 0.0, 100.0 ) - 50.0;
107-
alpha[ i ] = random_uniform( 0.0, 20.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
108-
m[ i ] = random_uniform( 0.0, 60.0 ) - 20.0;
109-
s[ i ] = random_uniform( 0.0, 20.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
106+
alpha[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
107+
s[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
108+
m[ i ] = random_uniform( -2.0, 2.0 );
109+
x[ i ] = random_uniform( m[ i ] + 0.1, m[ i ] + 20.0 );
110110
}
111111

112112
t = tic();

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

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

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

@@ -34,10 +35,10 @@ int main( void ) {
3435
int i;
3536

3637
for ( i = 0; i < 10; i++ ) {
37-
x = random_uniform( 0.0, 10.0 );
38-
alpha = random_uniform( 0.0, 10.0 );
39-
s = random_uniform( 0.0, 10.0 );
40-
m = random_uniform( 0.0, 10.0 );
38+
alpha = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
39+
s = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
40+
m = random_uniform( -2.0, 2.0 );
41+
x = random_uniform( m + 0.1, m + 10.0 );
4142
y = stdlib_base_dists_frechet_cdf( x, alpha, s, m );
4243
printf( "x: %lf, alpha: %lf, s: %lf, m: %lf, F(x;alpha,s,m): %lf\n", x, alpha, s, m, y );
4344
}

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

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

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/base/uniform' );
22+
var EPS = require( '@stdlib/constants/float64/eps' );
2223
var cdf = require( './../lib' );
2324

2425
var alpha;
@@ -29,10 +30,10 @@ var y;
2930
var i;
3031

3132
for ( i = 0; i < 100; i++ ) {
32-
alpha = randu() * 10.0;
33-
x = randu() * 10.0;
34-
s = randu() * 10.0;
35-
m = randu() * 10.0;
33+
alpha = uniform( EPS, 5.0 );
34+
s = uniform( EPS, 5.0 );
35+
m = uniform( -2.0, 2.0 );
36+
x = uniform( m + 0.1, m + 10.0 );
3637
y = cdf( x, alpha, s, m );
3738
console.log( 'x: %d, α: %d, s: %d, m: %d, F(x;α,s,m): %d', x.toFixed( 4 ), alpha.toFixed( 4 ), s.toFixed( 4 ), m.toFixed( 4 ), y.toFixed( 4 ) );
3839
}

lib/node_modules/@stdlib/stats/base/dists/frechet/cdf/include/stdlib/stats/base/dists/frechet/cdf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Returns the cumulative distribution function (CDF) for a Fréchet distribution with shape `alpha`, scale `s`, and location `m` at a value `x`.
30+
* Evaluates the cumulative distribution function (CDF) for a Fréchet distribution with shape `alpha`, scale `s`, and location `m` at a value `x`.
3131
*/
3232
double stdlib_base_dists_frechet_cdf( const double x, const double alpha, const double s, const double m );
3333

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"libpath": [],
7676
"dependencies": [
7777
"@stdlib/math/base/assert/is-nan",
78+
"@stdlib/constants/float64/eps",
7879
"@stdlib/math/base/special/pow",
7980
"@stdlib/math/base/special/exp"
8081
]

lib/node_modules/@stdlib/stats/base/dists/frechet/cdf/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323

2424

2525
/**
26-
* Returns the cumulative distribution function (CDF) for a Fréchet distribution with shape `alpha`, scale `s`, and location `m` at a value `x`.
26+
* Evaluates the cumulative distribution function (CDF) for a Fréchet distribution with shape `alpha`, scale `s`, and location `m` at a value `x`.
2727
*
2828
* @param x input value
2929
* @param alpha shape parameter
3030
* @param s scale parameter
3131
* @param m location parameter
32-
* @return skewness
32+
* @return evaluated CDF
3333
*
3434
* @example
35-
* double y = stdlib_base_frechet_cdf( 10.0, 2.0, 3.0, 2.0 );
35+
* double y = stdlib_base_dists_frechet_cdf( 10.0, 2.0, 3.0, 2.0 );
3636
* // returns ~0.869
3737
*/
3838
double stdlib_base_dists_frechet_cdf( const double x, const double alpha, const double s, const double m ) {

0 commit comments

Comments
 (0)