Skip to content

Commit 918c94a

Browse files
committed
refactor: update the example.c
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 4321303 commit 918c94a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/node_modules/@stdlib/stats/base/dists/hypergeometric/variance/examples/c/example.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/hypergeometric/variance.h"
20+
#include "stdlib/math/base/special/round.h"
2021
#include <stdlib.h>
2122
#include <stdio.h>
2223

23-
static int random_integer( const int min, const int max ) {
24-
return min + rand() % ( max - min + 1 );
24+
static double random_uniform( const double min, const double max ) {
25+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
26+
return min + ( v*(max-min) );
2527
}
2628

2729
int main( void ) {
@@ -36,9 +38,9 @@ int main( void ) {
3638
printf( "-------------------------------------------------" );
3739

3840
for ( i = 0; i < 10; i++ ) {
39-
N = random_integer( 10, 100 );
40-
K = random_integer( 1, N );
41-
n = random_integer( 1, N );
41+
N = stdlib_base_round(random_uniform(0.0, 20.0));
42+
K = stdlib_base_round(random_uniform(0.0, N));
43+
n = stdlib_base_round(random_uniform(0.0, K));
4244
v = stdlib_base_dists_hypergeometric_variance( N, K, n );
4345

4446
printf( "N: %lf, K: %lf, n: %lf, Variance: %lf\n", N, K, n, v );

lib/node_modules/@stdlib/stats/base/dists/hypergeometric/variance/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"libpath": [],
7373
"dependencies": [
7474
"@stdlib/math/base/assert/is-nonnegative-integer",
75+
"@stdlib/math/base/special/round",
7576
"@stdlib/constants/float64/pinf"
7677
]
7778
}

0 commit comments

Comments
 (0)