Skip to content

Commit d9eb485

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 f370792 commit d9eb485

File tree

1 file changed

+105
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/hypergeometric/pmf

1 file changed

+105
-0
lines changed

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

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,111 @@ for ( i = 0; i < 10; i++ ) {
157157

158158
<!-- /.examples -->
159159

160+
<!-- C interface documentation. -->
161+
162+
* * *
163+
164+
<section class="c">
165+
166+
## C APIs
167+
168+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
169+
170+
<section class="intro">
171+
172+
</section>
173+
174+
<!-- /.intro -->
175+
176+
<!-- C usage documentation. -->
177+
178+
<section class="usage">
179+
180+
### Usage
181+
182+
```c
183+
#include "stdlib/stats/base/dists/hypergeometric/pmf.h"
184+
```
185+
186+
#### stdlib_base_dists_hypergeometric_pmf( x, N, K, n )
187+
188+
Evaluates the probability mass function (PMF) for a hypergeometric distribution with population size `N`, subpopulation size `K`, and number of draws `n`.
189+
190+
```c
191+
double out = stdlib_base_dists_hypergeometric_stdev( 16, 11, 4 );
192+
// returns ~0.829
193+
```
194+
195+
The function accepts the following arguments:
196+
197+
- **x**: `[in] double` input value.
198+
- **N**: `[in] double` population size.
199+
- **K**: `[in] double` subpopulation size.
200+
- **n**: `[in] double` number of draws.
201+
202+
```c
203+
double stdlib_base_dists_hypergeometric_pmf ( const double x, const double N, const double K, const double n );
204+
```
205+
206+
</section>
207+
208+
<!-- /.usage -->
209+
210+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
211+
212+
<section class="notes">
213+
214+
</section>
215+
216+
<!-- /.notes -->
217+
218+
<!-- C API usage examples. -->
219+
220+
<section class="examples">
221+
222+
### Examples
223+
224+
```c
225+
#include "stdlib/stats/base/dists/hypergeometric/pmf.h"
226+
#include "stdlib/math/base/special/round.h"
227+
#include <stdlib.h>
228+
#include <stdio.h>
229+
230+
static double random_uniform( const double min, const double max ) {
231+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
232+
return min + ( v*(max-min) );
233+
}
234+
235+
int main( void ) {
236+
double N;
237+
double K;
238+
double n;
239+
double x;
240+
double pmf;
241+
int i;
242+
243+
for ( i = 0; i < 10; i++ ) {
244+
N = stdlib_base_round(random_uniform(1.0, 20.0));
245+
K = stdlib_base_round(random_uniform(0.0, N));
246+
n = stdlib_base_round(random_uniform(0.0, N));
247+
x = stdlib_base_round(random_uniform(0.0, n));
248+
pmf = stdlib_base_dists_hypergeometric_pmf( x, N, K, n );
249+
250+
printf( "N: %lf, K: %lf, n: %lf, x: %lf, PMF: %lf\n", N, K, n, x, pmf );
251+
}
252+
253+
return 0;
254+
}
255+
```
256+
257+
</section>
258+
259+
<!-- /.examples -->
260+
261+
</section>
262+
263+
<!-- /.c -->
264+
160265
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
161266

162267
<section class="related">

0 commit comments

Comments
 (0)