Skip to content

Commit d4275a9

Browse files
authored
chore: apply suggestions from code review
Signed-off-by: Philipp Burckhardt <[email protected]>
1 parent 3de0f0e commit d4275a9

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

lib/node_modules/@stdlib/stats/base/dists/uniform/mean/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ for ( i = 0; i < 10; i++ ) {
161161

162162
#### stdlib_base_dists_uniform_mean( a, b )
163163

164-
Returns the [mean][mean] of a [uniform][uniform-distribution] distribution with minimum value \( a \) and maximum value \( b \).
164+
Returns the [expected value][expected-value] of a [uniform][uniform-distribution] distribution with parameters `a` (minimum support) and `b` (maximum support).
165165

166166
```c
167167
double out = stdlib_base_dists_uniform_mean( 0.0, 1.0 );
@@ -170,8 +170,8 @@ double out = stdlib_base_dists_uniform_mean( 0.0, 1.0 );
170170

171171
The function accepts the following arguments:
172172

173-
- **a**: `[in] double` minimum value.
174-
- **b**: `[in] double` maximum value.
173+
- **a**: `[in] double` minimum support.
174+
- **b**: `[in] double` maximum support.
175175

176176
```c
177177
double stdlib_base_dists_uniform_mean( const double a, const double b );
@@ -200,15 +200,20 @@ double stdlib_base_dists_uniform_mean( const double a, const double b );
200200
#include <stdlib.h>
201201
#include <stdio.h>
202202
203+
static double random_uniform( const double min, const double max ) {
204+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
205+
return min + ( v*(max-min) );
206+
}
207+
203208
int main( void ) {
204209
double a;
205210
double b;
206211
double y;
207212
int i;
208213
209214
for ( i = 0; i < 25; i++ ) {
210-
a = (double)( rand() % 10 );
211-
b = a + (double)( rand() % 10 + 1 ); // ensure b > a
215+
a = random_uniform( 0.0, 10.0 );
216+
b = random_uniform( a, 20.0 ); // ensure b > a
212217
y = stdlib_base_dists_uniform_mean( a, b );
213218
printf( "a: %lf, b: %lf, E(X;a,b): %lf\n", a, b, y );
214219
}

lib/node_modules/@stdlib/stats/base/dists/uniform/mean/benchmark/c/benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ static double random_uniform( const double min, const double max ) {
9292
* @return elapsed time in seconds
9393
*/
9494
static double benchmark( void ) {
95-
double elapsed;
9695
double a[ 100 ];
9796
double b[ 100 ];
97+
double elapsed;
9898
double y;
9999
double t;
100100
int i;

lib/node_modules/@stdlib/stats/base/dists/uniform/mean/examples/c/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ int main( void ) {
3535
a = random_uniform( 0.0, 10.0 );
3636
b = random_uniform( a, 20.0 );
3737
y = stdlib_base_dists_uniform_mean( a, b );
38-
printf( "a: %lf , b: %lf , Mean: %lf\n", a, b, y );
38+
printf( "a: %lf , b: %lf , E(X;a,b): %lf\n", a, b, y );
3939
}
4040
}

lib/node_modules/@stdlib/stats/base/dists/uniform/mean/include/stdlib/stats/base/dists/uniform/mean.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 mean of a uniform distribution with lower bound `a` and upper bound `b`.
30+
* Returns the mean of a uniform distribution with minimum support `a` and maximum support `b`.
3131
*/
3232
double stdlib_base_dists_uniform_mean( const double a, const double b );
3333

lib/node_modules/@stdlib/stats/base/dists/uniform/mean/lib/native.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ var addon = require( './../src/addon.node' );
2929
* Returns the mean of a uniform distribution.
3030
*
3131
* @private
32-
* @param {number} a - lower bound
33-
* @param {number} b - upper bound
32+
* @param {number} a - minimum support
33+
* @param {number} b - maximum support
3434
* @returns {number} mean
3535
*
3636
* @example

lib/node_modules/@stdlib/stats/base/dists/uniform/mean/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
/**
2323
* Returns the mean of a uniform distribution.
2424
*
25-
* @param a lower bound
26-
* @param b upper bound
25+
* @param a minimum support
26+
* @param b maximum support
2727
* @return mean
2828
*
2929
* @example

0 commit comments

Comments
 (0)