Skip to content

Commit b482098

Browse files
committed
Auto-generated commit
1 parent bf1390e commit b482098

File tree

20 files changed

+61
-62
lines changed

20 files changed

+61
-62
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-12-23)
7+
## Unreleased (2024-12-24)
88

99
<section class="packages">
1010

@@ -2912,6 +2912,7 @@ A total of 17 people contributed to this release. Thank you to the following con
29122912

29132913
<details>
29142914

2915+
- [`b7867cb`](https://github.com/stdlib-js/stdlib/commit/b7867cbb3a4fc453e19203794402c36f19b264fd) - **chore:** minor clean-up _(by Philipp Burckhardt)_
29152916
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
29162917
- [`0ba282b`](https://github.com/stdlib-js/stdlib/commit/0ba282b89c384f06bbe3ff8ecd71982f05209606) - **chore:** minor clean-up _(by Philipp Burckhardt)_
29172918
- [`9f71ae0`](https://github.com/stdlib-js/stdlib/commit/9f71ae0ab3105190b6638768b83756e69d9146ea) - **chore:** address feedback and enable tests _(by Philipp Burckhardt)_

base/dists/bernoulli/mean/benchmark/c/benchmark.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,1).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static double rand_double( void ) {
83-
int r = rand();
84-
return (double)r / ( (double)RAND_MAX + 1.0 );
84+
static double random_uniform( const double min, const double max ) {
85+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -97,7 +99,7 @@ static double benchmark( void ) {
9799
int i;
98100

99101
for ( i = 0; i < 100; i++ ) {
100-
p[ i ] = rand_double();
102+
p[ i ] = random_uniform( 0.0, 1.0 );
101103
}
102104

103105
t = tic();

base/dists/bernoulli/mode/benchmark/c/benchmark.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,1).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static double rand_double( void ) {
83-
int r = rand();
84-
return (double)r / ( (double)RAND_MAX + 1.0 );
84+
static double random_uniform( const double min, const double max ) {
85+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -97,7 +99,7 @@ static double benchmark( void ) {
9799
int i;
98100

99101
for ( i = 0; i < 100; i++ ) {
100-
p[ i ] = rand_double();
102+
p[ i ] = random_uniform( 0.0, 1.0 );
101103
}
102104

103105
t = tic();

base/dists/exponential/mean/test/test.native.js

+2-12
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
2525
var tryRequire = require( '@stdlib/utils/try-require' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27-
var abs = require( '@stdlib/math/base/special/abs' );
2827
var NINF = require( '@stdlib/constants/float64/ninf' );
29-
var EPS = require( '@stdlib/constants/float64/eps' );
3028

3129

3230
// VARIABLES //
@@ -68,25 +66,17 @@ tape( 'if provided a rate parameter `lambda` that is not a nonnegative number, t
6866
t.end();
6967
});
7068

71-
tape( 'the function returns the mean of an exponential distribution', opts, function test( t ) {
69+
tape( 'the function returns the expected value of an exponential distribution', opts, function test( t ) {
7270
var expected;
7371
var lambda;
74-
var delta;
75-
var tol;
7672
var i;
7773
var y;
7874

7975
expected = data.expected;
8076
lambda = data.lambda;
8177
for ( i = 0; i < expected.length; i++ ) {
8278
y = mean( lambda[i] );
83-
if ( y === expected[ i ] ) {
84-
t.equal( y, expected[i], 'lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
85-
} else {
86-
delta = abs( y - expected[ i ] );
87-
tol = 2.0 * EPS * abs( expected[ i ] );
88-
t.ok( delta <= tol, 'within tolerance. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
89-
}
79+
t.equal( y, expected[i], 'lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
9080
}
9181
t.end();
9282
});

base/dists/f/skewness/benchmark/c/benchmark.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static double benchmark( void ) {
102102

103103
for ( i = 0; i < 100; i++ ) {
104104
d1[ i ] = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
105-
d2[ i ] = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
105+
d2[ i ] = random_uniform( 0.0, 10.0 ) + 6.0 + STDLIB_CONSTANT_FLOAT64_EPS;
106106
}
107107

108108
t = tic();

base/dists/gamma/kurtosis/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ for ( i = 0; i < 10; i++ ) {
170170

171171
#### stdlib_base_dists_gamma_kurtosis( alpha, beta )
172172

173-
Returns the kurtosis of a gamma distribution.
173+
Returns the [excess kurtosis][kurtosis] of a [gamma][gamma-distribution] distribution with parameters `alpha` (shape parameter) and `beta` (rate parameter).
174174

175175
```c
176176
double out = stdlib_base_dists_gamma_kurtosis( 1.0, 1.0 );

base/dists/gamma/kurtosis/src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @example
3030
* double y = stdlib_base_gamma_kurtosis( 1.0, 1.0 );
31-
* // returns 1.0
31+
* // returns 6.0
3232
*/
3333
double stdlib_base_dists_gamma_kurtosis( const double alpha, const double beta ) {
3434
if (

base/dists/gamma/mean/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ for ( i = 0; i < 10; i++ ) {
172172

173173
#### stdlib_base_dists_gamma_mean( alpha, beta )
174174

175-
Returns the mean of a gamma distribution.
175+
Returns the [expected value][expected-value] of a [gamma][gamma-distribution] distribution with parameters `alpha` (shape parameter) and `beta` (rate parameter).
176176

177177
```c
178178
double out = stdlib_base_dists_gamma_mean( 1.0, 1.0 );

base/dists/gamma/mean/include/stdlib/stats/base/dists/gamma/mean.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Returns the mean of a gamma distribution.
30+
* Returns the expected value of a gamma distribution.
3131
*/
3232
double stdlib_base_dists_gamma_mean( const double alpha, const double beta );
3333

base/dists/gamma/mean/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
#include "stdlib/stats/base/dists/gamma/mean.h"
2020

2121
/**
22-
* Returns the mean of a gamma distribution.
22+
* Returns the expected value of a gamma distribution.
2323
*
2424
* @param alpha shape parameter
2525
* @param beta rate parameter
26-
* @return mean
26+
* @return expected value
2727
*
2828
* @example
2929
* double y = stdlib_base_gamma_mean( 1.0, 1.0 );

base/dists/gamma/mean/test/test.native.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ tape( 'the function returns the mean of a gamma distribution', opts, function te
121121
t.equal( y, expected[i], 'alpha: '+alpha[i]+', beta: '+beta[i]+', y: '+y+', expected: '+expected[i] );
122122
} else {
123123
delta = abs( y - expected[ i ] );
124-
tol = 2.0 * EPS * abs( expected[ i ] );
124+
tol = 1.0 * EPS * abs( expected[ i ] );
125125
t.ok( delta <= tol, 'within tolerance. alpha: '+alpha[i]+'. beta: '+beta[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
126126
}
127127
}

base/dists/poisson/mean/benchmark/c/benchmark.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,20).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static double rand_double( void ) {
83-
int r = rand();
84-
return 20.0*(double)r / ( (double)RAND_MAX + 1.0 );
84+
static double random_uniform( const double min, const double max ) {
85+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -97,7 +99,7 @@ static double benchmark( void ) {
9799
int i;
98100

99101
for ( i = 0; i < 100; i++ ) {
100-
lambda[ i ] = rand_double();
102+
lambda[ i ] = random_uniform( 0.0, 20.0 );
101103
}
102104

103105
t = tic();

base/dists/triangular/mean/include/stdlib/stats/base/dists/triangular/mean.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Returns the mean of a triangular distribution with lower bound `a`, upper bound `b`, and mode `c`.
30+
* Returns the mean of a triangular distribution.
3131
*/
3232
double stdlib_base_dists_triangular_mean( const double a, const double b, const double c );
3333

base/dists/triangular/mean/lib/native.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ var addon = require( './../src/addon.node' );
2929
* Returns the expected value (mean) of a triangular distribution.
3030
*
3131
* @private
32-
* @param {NonNegativeNumber} a - lower bound
33-
* @param {NonNegativeNumber} b - upper bound
34-
* @param {NonNegativeNumber} c - mode (peak)
32+
* @param {NonNegativeNumber} a - minimum support
33+
* @param {NonNegativeNumber} b - maximum support
34+
* @param {NonNegativeNumber} c - mode
3535
* @returns {NonNegativeNumber} expected value (mean)
3636
*
3737
* @example

base/dists/triangular/mode/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ int main( void ) {
222222
for ( i = 0; i < 25; i++ ) {
223223
a = random_uniform( 0.0, 10.0 );
224224
b = random_uniform( 0.0, 10.0 ) + a;
225-
c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
225+
c = random_uniform( a, b ); // mode between a and b
226226
y = stdlib_base_dists_triangular_mode( a, b, c );
227227
printf( "a: %lf, b: %lf, c: %lf, M(X;a,b,c): %lf\n", a, b, c, y );
228228
}

base/dists/triangular/mode/benchmark/c/benchmark.c

+10-8
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,20).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static double rand_double( void ) {
83-
int r = rand();
84-
return 20.0*(double)r / ( (double)RAND_MAX + 1.0 );
84+
static double random_uniform( const double min, const double max ) {
85+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -98,9 +100,9 @@ static double benchmark( void ) {
98100

99101
// Generate random parameters for the triangular distribution
100102
for ( i = 0; i < 100; i++ ) {
101-
a[ i ] = rand_double() * 20.0; // Lower bound
102-
b[ i ] = ( rand_double() * 20.0 ) + a[ i ]; // Upper bound
103-
c[ i ] = ( rand_double() * ( b[i] - a[i] ) ) + a[i]; // Mode
103+
a[ i ] = random_uniform( 0.0, 20.0 ); // Lower bound
104+
b[ i ] = random_uniform( a[i], 40.0 ); // Upper bound
105+
c[ i ] = random_uniform( a[i], b[i] ); // Mode
104106
}
105107

106108
t = tic();

base/dists/triangular/mode/examples/c/example.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main( void ) {
3535
for ( i = 0; i < 25; i++ ) {
3636
a = random_uniform( 0.0, 10.0 );
3737
b = random_uniform( 0.0, 10.0 ) + a;
38-
c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
38+
c = random_uniform( a, b ); // mode between a and b
3939
y = stdlib_base_dists_triangular_mode( a, b, c );
4040
printf( "a: %lf, b: %lf, c: %lf, M(X;a,b,c): %lf\n", a, b, c, y );
4141
}

base/dists/triangular/mode/include/stdlib/stats/base/dists/triangular/mode.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Returns the mode of a triangular distribution with lower bound `a`, upper bound `b`, and mode `c`.
30+
* Returns the mode of a triangular distribution.
3131
*/
3232
double stdlib_base_dists_triangular_mode( const double a, const double b, const double c );
3333

base/dists/triangular/mode/lib/native.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ var addon = require( './../src/addon.node' );
2929
* Returns the mode of a triangular distribution.
3030
*
3131
* @private
32-
* @param {NonNegativeNumber} a - lower bound
33-
* @param {NonNegativeNumber} b - upper bound
34-
* @param {NonNegativeNumber} c - mode (peak)
35-
* @returns {NonNegativeNumber} mode
32+
* @param {number} a - minimum support
33+
* @param {number} b - maximum support
34+
* @param {number} c - mode
35+
* @returns {number} mode
3636
*
3737
* @example
3838
* var v = mode( 0.0, 10.0, 5.0 );

base/dists/triangular/mode/src/main.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
/**
2323
* Returns the mode of a triangular distribution.
2424
*
25-
* @param a lower bound
26-
* @param b upper bound
27-
* @param c mode (peak)
25+
* @param a minimum support
26+
* @param b maximum support
27+
* @param c mode
2828
* @returns mode
2929
*
3030
* @example
31-
* var v = mode( 0.0, 10.0, 5.0 );
31+
* double v = mode( 0.0, 10.0, 5.0 );
3232
* // returns 5.0
3333
*/
3434
double stdlib_base_dists_triangular_mode( const double a, const double b, const double c ) {

0 commit comments

Comments
 (0)