File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
lib/node_modules/@stdlib/stats/base/dists/bernoulli/quantile/benchmark/c Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,18 @@ static double tic( void ) {
7474 return (double )now .tv_sec + (double )now .tv_usec /1.0e6 ;
7575}
7676
77+ /**
78+ * Generates a random number on the interval [min,max).
79+ *
80+ * @param min minimum value (inclusive)
81+ * @param max maximum value (exclusive)
82+ * @return random number
83+ */
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 ) );
87+ }
88+
7789/**
7890* Runs a benchmark.
7991*
@@ -88,9 +100,8 @@ static double benchmark( void ) {
88100 int i ;
89101
90102 for ( i = 0 ; i < 100 ; i ++ ) {
91-
92- r [ i ] = (double )rand () / ( (double )RAND_MAX + 1.0 );
93- p [ i ] = (double )rand () / ( (double )RAND_MAX + 1.0 );
103+ r [ i ] = random_uniform ( 0.0 , 1.0 );
104+ p [ i ] = random_uniform ( 0.0 , 1.0 );
94105 }
95106
96107 t = tic ();
You can’t perform that action at this time.
0 commit comments