Skip to content

Commit 4321303

Browse files
committed
docs: update README with C API documentation
--- 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 ecd7086 commit 4321303

File tree

1 file changed

+100
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/hypergeometric/variance

1 file changed

+100
-0
lines changed

lib/node_modules/@stdlib/stats/base/dists/hypergeometric/variance/README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,106 @@ for ( i = 0; i < 10; i++ ) {
147147

148148
<!-- /.examples -->
149149

150+
<!-- C interface documentation. -->
151+
152+
* * *
153+
154+
<section class="c">
155+
156+
## C APIs
157+
158+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
159+
160+
<section class="intro">
161+
162+
</section>
163+
164+
<!-- /.intro -->
165+
166+
<!-- C usage documentation. -->
167+
168+
<section class="usage">
169+
170+
### Usage
171+
172+
```c
173+
#include "stdlib/stats/base/dists/hypergeometric/variance.h"
174+
```
175+
176+
#### stdlib_base_dists_hypergeometric_variance( N, K, n )
177+
178+
Returns the variance of a hypergeometric distribution.
179+
180+
```c
181+
double out = stdlib_base_dists_hypergeometric_variance( 16, 11, 4 );
182+
// returns ~0.688
183+
```
184+
185+
The function accepts the following arguments:
186+
187+
- **N**: `[in] double` population size.
188+
- **K**: `[in] double` subpopulation size.
189+
- **n**: `[in] double` number of draws.
190+
191+
```c
192+
double stdlib_base_dists_hypergeometric_variance( const double N, const double K, const double n );
193+
```
194+
195+
</section>
196+
197+
<!-- /.usage -->
198+
199+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
200+
201+
<section class="notes">
202+
203+
</section>
204+
205+
<!-- /.notes -->
206+
207+
<!-- C API usage examples. -->
208+
209+
<section class="examples">
210+
211+
### Examples
212+
213+
```c
214+
#include "stdlib/stats/base/dists/hypergeometric/variance.h"
215+
#include <stdlib.h>
216+
#include <stdio.h>
217+
218+
static int random_integer( const int min, const int max ) {
219+
return min + rand() % ( max - min + 1 );
220+
}
221+
222+
int main( void ) {
223+
double N;
224+
double K;
225+
double n;
226+
double v;
227+
int i;
228+
229+
for ( i = 0; i < 10; i++ ) {
230+
N = random_integer( 10, 100 );
231+
K = random_integer( 1, N );
232+
n = random_integer( 1, N );
233+
v = stdlib_base_dists_hypergeometric_variance( N, K, n );
234+
235+
printf( "N: %lf, K: %lf, n: %lf, Variance: %lf\n", N, K, n, v );
236+
}
237+
238+
return 0;
239+
}
240+
```
241+
242+
</section>
243+
244+
<!-- /.examples -->
245+
246+
</section>
247+
248+
<!-- /.c -->
249+
150250
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
151251

152252
<section class="references">

0 commit comments

Comments
 (0)