Skip to content

Commit da14b77

Browse files
Planeshifterkgryte
andauthored
chore: move number generation to function
Co-authored-by: Athan <[email protected]> Signed-off-by: Philipp Burckhardt <[email protected]>
1 parent 09540e5 commit da14b77

File tree

1 file changed

+8
-3
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/arcsine/cdf

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ double stdlib_base_dists_arcsine_cdf( const double x, const double a, const doub
205205
#include <stdlib.h>
206206
#include <stdio.h>
207207
208+
static double random_uniform( const double min, const double max ) {
209+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
210+
return min + ( v*(max-min) );
211+
}
212+
208213
int main( void ) {
209214
double x;
210215
double a;
@@ -213,9 +218,9 @@ int main( void ) {
213218
int i;
214219
215220
for ( i = 0; i < 25; i++ ) {
216-
x = ( (double)rand() / (double)RAND_MAX ) * 20.0 - 10.0;
217-
a = ( (double)rand() / (double)RAND_MAX ) * 20.0 - 20.0;
218-
b = a + ( (double)rand() / (double)RAND_MAX ) * 40.0;
221+
x = random_uniform( -10.0, 10.0 );
222+
a = random_uniform( -20.0, 0.0 );
223+
b = random_uniform( a, a+40.0 );
219224
y = stdlib_base_dists_arcsine_cdf( x, a, b );
220225
printf( "x: %lf, a: %lf, b: %lf, F(x;a,b): %lf\n", x, a, b, y );
221226
}

0 commit comments

Comments
 (0)