Skip to content

Commit 67f3f9e

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 efe9448 commit 67f3f9e

File tree

1 file changed

+106
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/hypergeometric/logpmf

1 file changed

+106
-0
lines changed

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

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,112 @@ 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/logpmf.h"
184+
```
185+
186+
#### stdlib_base_dists_hypergeometric_logpmf( x, N, K, n )
187+
188+
Evaluates the natural logarithm of the probability mass function (PMF) for a hypergeometric distribution.
189+
190+
```c
191+
double out = stdlib_base_dists_hypergeometric_logpmf( 1.0, 8, 4, 2 );
192+
// returns ~-0.56
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_logpmf ( 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/logpmf.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 log_pmf;
241+
int i;
242+
243+
for ( i = 0; i < 10; i++ ) {
244+
N = stdlib_base_round(random_uniform(5.0, 20.0));
245+
K = stdlib_base_round(random_uniform(0.0, N));
246+
n = stdlib_base_round(random_uniform(0.0, K));
247+
x = stdlib_base_round(random_uniform(0.0, n));
248+
249+
log_pmf = stdlib_base_dists_hypergeometric_logpmf( x, N, K, n );
250+
251+
printf( "N: %lf, K: %lf, n: %lf, x: %lf, Log PMF: %lf\n", N, K, n, x, log_pmf );
252+
}
253+
254+
return 0;
255+
}
256+
```
257+
258+
</section>
259+
260+
<!-- /.examples -->
261+
262+
</section>
263+
264+
<!-- /.c -->
265+
160266
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
161267

162268
<section class="related">

0 commit comments

Comments
 (0)