Skip to content

Commit 3aaa80e

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

File tree

1 file changed

+7
-3
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/uniform/median/examples/c

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include "stdlib/stats/base/dists/uniform/median.h"
2020
#include <stdlib.h>
2121
#include <stdio.h>
22+
static double random_uniform( const double min, const double max ) {
23+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
24+
return min + ( v*(max-min) );
25+
}
2226

2327
int main( void ) {
2428
double a;
@@ -27,9 +31,9 @@ int main( void ) {
2731
int i;
2832

2933
for ( i = 0; i < 25; i++ ) {
30-
a = (double)rand() / ( (double)RAND_MAX + 1.0 ) * 100.0;
31-
b = a + ( (double)rand() / ( (double)RAND_MAX + 1.0 ) * 50.0 );
34+
a = random_uniform( 0.0, 10.0 );
35+
b = random_uniform( a, 20.0 );
3236
y = stdlib_base_dists_uniform_median( a, b );
33-
printf( "a: %lf , b: %lf , Median: %lf\n", a, b, y );
37+
printf( "a: %lf , b: %lf , Median(X;a,b): %lf\n", a, b, y );
3438
}
3539
}

0 commit comments

Comments
 (0)