Skip to content

Commit d77ab08

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 35646f7 commit d77ab08

File tree

1 file changed

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

1 file changed

+98
-0
lines changed

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

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

128128
<!-- /.examples -->
129129

130+
<!-- C interface documentation. -->
131+
132+
* * *
133+
134+
<section class="c">
135+
136+
## C APIs
137+
138+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
139+
140+
<section class="intro">
141+
142+
</section>
143+
144+
<!-- /.intro -->
145+
146+
<!-- C usage documentation. -->
147+
148+
<section class="usage">
149+
150+
### Usage
151+
152+
```c
153+
#include "stdlib/stats/base/dists/degenerate/pdf.h"
154+
```
155+
156+
#### stdlib_base_dists_degenerate_pdf( x, mu )
157+
158+
Evaluates the probability density function (PDF) for a degenerate distribution centered at `mu`.
159+
160+
```c
161+
double out = stdlib_base_dists_degenerate_pdf( 2.0, 3.0 );
162+
// returns 0.0
163+
```
164+
165+
The function accepts the following arguments:
166+
167+
- **x**: `[in] double` input value.
168+
- **mu**: `[in] double` constant value of the distribution.
169+
170+
```c
171+
double stdlib_base_dists_degenerate_pdf( const double x, const double mu );
172+
```
173+
174+
</section>
175+
176+
<!-- /.usage -->
177+
178+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
179+
180+
<section class="notes">
181+
182+
</section>
183+
184+
<!-- /.notes -->
185+
186+
<!-- C API usage examples. -->
187+
188+
<section class="examples">
189+
190+
### Examples
191+
192+
```c
193+
#include "stdlib/stats/base/dists/degenerate/pdf.h"
194+
#include <stdlib.h>
195+
#include <stdio.h>
196+
197+
static double random_uniform( const double min, const double max ) {
198+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
199+
return min + ( v * ( max - min ) );
200+
}
201+
202+
int main( void ) {
203+
double x;
204+
double mu;
205+
double result;
206+
int i;
207+
208+
for ( i = 0; i < 10; i++ ) {
209+
x = random_uniform( -10.0, 10.0 );
210+
mu = random_uniform( -20.0, 20.0 );
211+
result = stdlib_base_dists_degenerate_pdf( x, mu );
212+
213+
printf( "x: %lf, mu: %lf, PDF: %lf \n", x, mu, result );
214+
}
215+
216+
return 0;
217+
}
218+
```
219+
220+
</section>
221+
222+
<!-- /.examples -->
223+
224+
</section>
225+
226+
<!-- /.c -->
227+
130228
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
131229

132230
<section class="related">

0 commit comments

Comments
 (0)