Skip to content

Commit cdcbf8c

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 beb0359 commit cdcbf8c

File tree

1 file changed

+100
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/negative-binomial/mgf

1 file changed

+100
-0
lines changed

lib/node_modules/@stdlib/stats/base/dists/negative-binomial/mgf/README.md

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

177177
<!-- /.examples -->
178178

179+
<!-- C interface documentation. -->
180+
181+
* * *
182+
183+
<section class="c">
184+
185+
## C APIs
186+
187+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
188+
189+
<section class="intro">
190+
191+
</section>
192+
193+
<!-- /.intro -->
194+
195+
<!-- C usage documentation. -->
196+
197+
<section class="usage">
198+
199+
### Usage
200+
201+
```c
202+
#include "stdlib/stats/base/dists/negative-binomial/mgf.h"
203+
```
204+
205+
#### stdlib_base_negative_binomial_mgf( t, r, p )
206+
207+
Evaluates the moment-generating function (MGF) for a negative binomial distribution.ion function (CDF) for an arcsine distribution.
208+
209+
```c
210+
double out = stdlib_base_negative_binomial_mgf( 0.05, 20.0, 0.8 );
211+
// returns ~267.839
212+
```
213+
214+
The function accepts the following arguments:
215+
216+
- **t**: `[in] double` input value.
217+
- **r**: `[in] double` number of successes until experiment is stopped.
218+
- **p**: `[in] double` success probability.
219+
220+
```c
221+
double stdlib_base_negative_binomial_mgf(const double t, const double r, const double p );
222+
```
223+
224+
</section>
225+
226+
<!-- /.usage -->
227+
228+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
229+
230+
<section class="notes">
231+
232+
</section>
233+
234+
<!-- /.notes -->
235+
236+
<!-- C API usage examples. -->
237+
238+
<section class="examples">
239+
240+
### Examples
241+
242+
```c
243+
#include "stdlib/stats/base/dists/negative-binomial/mgf.h"
244+
#include <stdlib.h>
245+
#include <stdio.h>
246+
247+
static double random_uniform( const double min, const double max ) {
248+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
249+
return min + ( v * ( max - min ) );
250+
}
251+
252+
int main( void ) {
253+
double t;
254+
double r;
255+
double p;
256+
double y;
257+
int i;
258+
259+
for ( i = 0; i < 25; i++ ) {
260+
t = random_uniform( -1.0, 1.0 );
261+
r = random_uniform( 1.0, 10.0 ); // r must be positive
262+
p = random_uniform( 0.0, 1.0 ); // p must be between 0 and 1
263+
y = stdlib_base_negative_binomial_mgf( t, r, p );
264+
printf( "t: %lf, r: %lf, p: %lf, MGF(t;r,p): %lf\n", t, r, p, y );
265+
}
266+
267+
return 0;
268+
}
269+
```
270+
271+
</section>
272+
273+
<!-- /.examples -->
274+
275+
</section>
276+
277+
<!-- /.c -->
278+
179279
<!-- 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. -->
180280

181281
<section class="references">

0 commit comments

Comments
 (0)