Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Dec 24, 2024
1 parent 2c5b2e6 commit 553bfd6
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="release" id="unreleased">

## Unreleased (2024-12-23)
## Unreleased (2024-12-24)

<section class="features">

Expand Down Expand Up @@ -34,6 +34,7 @@ This release closes the following issue:

<details>

- [`b7867cb`](https://github.com/stdlib-js/stdlib/commit/b7867cbb3a4fc453e19203794402c36f19b264fd) - **chore:** minor clean-up _(by Philipp Burckhardt)_
- [`603c766`](https://github.com/stdlib-js/stdlib/commit/603c76686fc8de480628e5b96efd9733b1f059b5) - **test:** only conditionally run tests _(by Philipp Burckhardt)_
- [`daf43b2`](https://github.com/stdlib-js/stdlib/commit/daf43b2052a0ad89fa4c72caee6d7caedcc4cc38) - **feat:** add C implementation for `stats/base/dists/triangular/mode` [(#4008)](https://github.com/stdlib-js/stdlib/pull/4008) _(by Prashant Kumar Yadav, Philipp Burckhardt)_

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ int main( void ) {
for ( i = 0; i < 25; i++ ) {
a = random_uniform( 0.0, 10.0 );
b = random_uniform( 0.0, 10.0 ) + a;
c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
c = random_uniform( a, b ); // mode between a and b
y = stdlib_base_dists_triangular_mode( a, b, c );
printf( "a: %lf, b: %lf, c: %lf, M(X;a,b,c): %lf\n", a, b, c, y );
}
Expand Down
18 changes: 10 additions & 8 deletions benchmark/c/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ static double tic( void ) {
}

/**
* Generates a random number on the interval [0,20).
* Generates a random number on the interval [min,max).
*
* @return random number
* @param min minimum value (inclusive)
* @param max maximum value (exclusive)
* @return random number
*/
static double rand_double( void ) {
int r = rand();
return 20.0*(double)r / ( (double)RAND_MAX + 1.0 );
static double random_uniform( const double min, const double max ) {
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
return min + ( v*(max-min) );
}

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

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

t = tic();
Expand Down
2 changes: 1 addition & 1 deletion examples/c/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main( void ) {
for ( i = 0; i < 25; i++ ) {
a = random_uniform( 0.0, 10.0 );
b = random_uniform( 0.0, 10.0 ) + a;
c = a + (b - a) * random_uniform( 0.0, 1.0 ); // mode between a and b
c = random_uniform( a, b ); // mode between a and b
y = stdlib_base_dists_triangular_mode( a, b, c );
printf( "a: %lf, b: %lf, c: %lf, M(X;a,b,c): %lf\n", a, b, c, y );
}
Expand Down
2 changes: 1 addition & 1 deletion include/stdlib/stats/base/dists/triangular/mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
#endif

/**
* Returns the mode of a triangular distribution with lower bound `a`, upper bound `b`, and mode `c`.
* Returns the mode of a triangular distribution.
*/
double stdlib_base_dists_triangular_mode( const double a, const double b, const double c );

Expand Down
8 changes: 4 additions & 4 deletions lib/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ var addon = require( './../src/addon.node' );
* Returns the mode of a triangular distribution.
*
* @private
* @param {NonNegativeNumber} a - lower bound
* @param {NonNegativeNumber} b - upper bound
* @param {NonNegativeNumber} c - mode (peak)
* @returns {NonNegativeNumber} mode
* @param {number} a - minimum support
* @param {number} b - maximum support
* @param {number} c - mode
* @returns {number} mode
*
* @example
* var v = mode( 0.0, 10.0, 5.0 );
Expand Down
8 changes: 4 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
/**
* Returns the mode of a triangular distribution.
*
* @param a lower bound
* @param b upper bound
* @param c mode (peak)
* @param a minimum support
* @param b maximum support
* @param c mode
* @returns mode
*
* @example
* var v = mode( 0.0, 10.0, 5.0 );
* double v = mode( 0.0, 10.0, 5.0 );
* // returns 5.0
*/
double stdlib_base_dists_triangular_mode( const double a, const double b, const double c ) {
Expand Down

0 comments on commit 553bfd6

Please sign in to comment.