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 ) {
74
74
return (double )now .tv_sec + (double )now .tv_usec /1.0e6 ;
75
75
}
76
76
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
+
77
89
/**
78
90
* Runs a benchmark.
79
91
*
@@ -88,9 +100,8 @@ static double benchmark( void ) {
88
100
int i ;
89
101
90
102
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 );
94
105
}
95
106
96
107
t = tic ();
You can’t perform that action at this time.
0 commit comments