Skip to content

Commit 79b793b

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 11f3f10 commit 79b793b

File tree

1 file changed

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

1 file changed

+98
-0
lines changed

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

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

9898
<!-- /.examples -->
9999

100+
<!-- C interface documentation. -->
101+
102+
* * *
103+
104+
<section class="c">
105+
106+
## C APIs
107+
108+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
109+
110+
<section class="intro">
111+
112+
</section>
113+
114+
<!-- /.intro -->
115+
116+
<!-- C usage documentation. -->
117+
118+
<section class="usage">
119+
120+
### Usage
121+
122+
```c
123+
#include "stdlib/stats/base/dists/degenerate/pmf.h"
124+
```
125+
126+
#### stdlib_base_dists_degenerate_pmf( x, mu )
127+
128+
Evaluates the probability mass function (PDF) for a degenerate distribution centered at `mu`.
129+
130+
```c
131+
double out = stdlib_base_dists_degenerate_pmf( 2.0, 3.0 );
132+
// returns 0.0
133+
```
134+
135+
The function accepts the following arguments:
136+
137+
- **x**: `[in] double` input value.
138+
- **mu**: `[in] double` constant value of the distribution.
139+
140+
```c
141+
double stdlib_base_dists_degenerate_pmf( const double x, const double mu );
142+
```
143+
144+
</section>
145+
146+
<!-- /.usage -->
147+
148+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
149+
150+
<section class="notes">
151+
152+
</section>
153+
154+
<!-- /.notes -->
155+
156+
<!-- C API usage examples. -->
157+
158+
<section class="examples">
159+
160+
### Examples
161+
162+
```c
163+
#include "stdlib/stats/base/dists/degenerate/pmf.h"
164+
#include <stdlib.h>
165+
#include <stdio.h>
166+
167+
static double random_uniform( const double min, const double max ) {
168+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
169+
return min + ( v * ( max - min ) );
170+
}
171+
172+
int main( void ) {
173+
double x;
174+
double mu;
175+
double result;
176+
int i;
177+
178+
for ( i = 0; i < 10; i++ ) {
179+
x = random_uniform( -10.0, 10.0 );
180+
mu = random_uniform( -20.0, 20.0 );
181+
result = stdlib_base_dists_degenerate_pmf( x, mu );
182+
183+
printf( "x: %lf, mu: %lf, PMF: %lf \n", x, mu, result );
184+
}
185+
186+
return 0;
187+
}
188+
```
189+
190+
</section>
191+
192+
<!-- /.examples -->
193+
194+
</section>
195+
196+
<!-- /.c -->
197+
100198
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
101199

102200
<section class="related">

0 commit comments

Comments
 (0)