Skip to content

Commit 1b55992

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 1a5005d commit 1b55992

File tree

1 file changed

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

1 file changed

+100
-0
lines changed

lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/README.md

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

152152
<!-- /.examples -->
153153

154+
<!-- C interface documentation. -->
155+
156+
* * *
157+
158+
<section class="c">
159+
160+
## C APIs
161+
162+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
163+
164+
<section class="intro">
165+
166+
</section>
167+
168+
<!-- /.intro -->
169+
170+
<!-- C usage documentation. -->
171+
172+
<section class="usage">
173+
174+
### Usage
175+
176+
```c
177+
#include "stdlib/stats/base/dists/chisquare/mgf.h"
178+
```
179+
180+
#### stdlib_base_dists_chisquare_mgf( t, k )
181+
182+
Evaluates the moment-generating function (MGF) for a chi-squared distribution
183+
* with degrees of freedom `k` at a value `t`.
184+
185+
```c
186+
double out = stdlib_base_dists_chisquare_mgf( 0.4, 2.0 );
187+
// returns ~5.0
188+
```
189+
190+
The function accepts the following arguments:
191+
192+
- **t**: `[in] double` input value.
193+
- **k**: `[in] double` degrees of freedom (must be non-negative).
194+
195+
```c
196+
double stdlib_base_dists_chisquare_mgf( const double t, const double k );
197+
```
198+
199+
</section>
200+
201+
<!-- /.usage -->
202+
203+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
204+
205+
<section class="notes">
206+
207+
</section>
208+
209+
<!-- /.notes -->
210+
211+
<!-- C API usage examples. -->
212+
213+
<section class="examples">
214+
215+
### Examples
216+
217+
```c
218+
#include "stdlib/stats/base/dists/chisquare/mgf.h"
219+
#include <stdlib.h>
220+
#include <stdio.h>
221+
222+
static double random_uniform( const double min, const double max ) {
223+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
224+
return min + ( v * ( max - min ) );
225+
}
226+
227+
int main( void ) {
228+
double t;
229+
double k;
230+
double result;
231+
int i;
232+
233+
for ( i = 0; i < 10; i++ ) {
234+
t = random_uniform( -0.5, 0.4 );
235+
k = random_uniform( 0.1, 10.0 );
236+
237+
result = stdlib_base_dists_chisquare_mgf( t, k );
238+
239+
printf( "t: %lf, k: %lf, MGF: %lf \n", t, k, result );
240+
}
241+
242+
return 0;
243+
}
244+
```
245+
246+
</section>
247+
248+
<!-- /.examples -->
249+
250+
</section>
251+
252+
<!-- /.c -->
253+
154254
<!-- 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. -->
155255

156256
<section class="references">

0 commit comments

Comments
 (0)