Skip to content

Commit 70b32ba

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 4b897d8 commit 70b32ba

File tree

1 file changed

+98
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/degenerate/mgf

1 file changed

+98
-0
lines changed

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

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,104 @@ for ( i = 0; i < 100; i++ ) {
132132

133133
<!-- /.examples -->
134134

135+
<!-- C interface documentation. -->
136+
137+
* * *
138+
139+
<section class="c">
140+
141+
## C APIs
142+
143+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
144+
145+
<section class="intro">
146+
147+
</section>
148+
149+
<!-- /.intro -->
150+
151+
<!-- C usage documentation. -->
152+
153+
<section class="usage">
154+
155+
### Usage
156+
157+
```c
158+
#include "stdlib/stats/base/dists/degenerate/mgf.h"
159+
```
160+
161+
#### stdlib_base_dists_degenerate_mgf( mu )
162+
163+
Evaluates the moment-generating function (MGF) for a degenerate distribution centered at `mu`.
164+
165+
```c
166+
double out = stdlib_base_dists_degenerate_mgf( 1.0, 1.0 );
167+
// returns ~2.718
168+
```
169+
170+
The function accepts the following arguments:
171+
172+
- **t**: `[in] double` input value.
173+
- **mu**: `[in] double` value at which to center the distribution.
174+
175+
```c
176+
double stdlib_base_dists_degenerate_mgf( const double t, const double mu );
177+
```
178+
179+
</section>
180+
181+
<!-- /.usage -->
182+
183+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
184+
185+
<section class="notes">
186+
187+
</section>
188+
189+
<!-- /.notes -->
190+
191+
<!-- C API usage examples. -->
192+
193+
<section class="examples">
194+
195+
### Examples
196+
197+
```c
198+
#include "stdlib/stats/base/dists/degenerate/mgf.h"
199+
#include <stdlib.h>
200+
#include <stdio.h>
201+
202+
static double random_uniform( const double min, const double max ) {
203+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
204+
return min + ( v * ( max - min ) );
205+
}
206+
207+
int main( void ) {
208+
double t;
209+
double mu;
210+
double result;
211+
int i;
212+
213+
for ( i = 0; i < 10; i++ ) {
214+
t = random_uniform( -10.0, 10.0 );
215+
mu = random_uniform( -20.0, 20.0 );
216+
result = stdlib_base_dists_degenerate_mgf( t, mu );
217+
218+
printf( "t: %lf, mu: %lf, MGF: %lf\n", t, mu, result );
219+
}
220+
221+
return 0;
222+
}
223+
```
224+
225+
</section>
226+
227+
<!-- /.examples -->
228+
229+
</section>
230+
231+
<!-- /.c -->
232+
135233
<!-- 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. -->
136234

137235
<section class="references">

0 commit comments

Comments
 (0)