Skip to content

Commit 2105d73

Browse files
committed
docs: update readme to include C API
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 30f62d2 commit 2105d73

1 file changed

Lines changed: 100 additions & 1 deletion

File tree

  • lib/node_modules/@stdlib/stats/base/dists/poisson/pmf

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

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var pmf = require( '@stdlib/stats/base/dists/poisson/pmf' );
5555

5656
#### pmf( x, lambda )
5757

58-
Evaluates the [probability mass function][pmf] (PMF) of a [Poisson][poisson-distribution] distribution with mean parameter `lambda`.
58+
Evaluates the [probability mass function][pmf] (PMF) of a [Poisson][poisson-distribution] distribution with mean parameter `lambda` at value `x`.
5959

6060
```javascript
6161
var y = pmf( 4.0, 3.0 );
@@ -140,6 +140,105 @@ logEachMap( 'x: %d, λ: %0.4f, P(X=x;λ): %0.4f', x, lambda, pmf );
140140

141141
<!-- /.examples -->
142142

143+
<!-- C interface documentation. -->
144+
145+
* * *
146+
147+
<section class="c">
148+
149+
## C APIs
150+
151+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
152+
153+
<section class="intro">
154+
155+
</section>
156+
157+
<!-- /.intro -->
158+
159+
<!-- C usage documentation. -->
160+
161+
<section class="usage">
162+
163+
### Usage
164+
165+
```c
166+
#include "stdlib/stats/base/dists/poisson/pmf.h"
167+
```
168+
169+
#### stdlib_base_dists_poisson_pmf( x, lambda )
170+
171+
Evaluates the [probability mass function][pmf] (PMF) of a [Poisson][poisson-distribution] distribution with mean parameter `lambda` at value `x`.
172+
173+
```c
174+
double out = stdlib_base_dists_poisson_pmf( 4.0, 3.0 );
175+
// returns ~0.168
176+
```
177+
178+
The function accepts the following arguments:
179+
180+
- **x**: `[in] double` value at which to evaluate the PMF.
181+
- **lambda**: `[in] double` mean parameter.
182+
183+
```c
184+
double stdlib_base_dists_poisson_pmf( const double x, const double lambda );
185+
```
186+
187+
</section>
188+
189+
<!-- /.usage -->
190+
191+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
192+
193+
<section class="notes">
194+
195+
</section>
196+
197+
<!-- /.notes -->
198+
199+
<!-- C API usage examples. -->
200+
201+
<section class="examples">
202+
203+
### Examples
204+
205+
```c
206+
#include "stdlib/stats/base/dists/poisson/pmf.h"
207+
#include <stdlib.h>
208+
#include <stdio.h>
209+
210+
static double random_uniform( const double min, const double max ) {
211+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
212+
return min + ( v*(max-min) );
213+
}
214+
215+
static int random_discrete_uniform( const int min, const int max ) {
216+
return min + ( rand() % ( max - min + 1 ) );
217+
}
218+
219+
int main( void ) {
220+
double lambda;
221+
double y;
222+
int x;
223+
int i;
224+
225+
for ( i = 0; i < 10; i++ ) {
226+
x = random_discrete_uniform( 0, 10 );
227+
lambda = random_uniform( 0.0, 20.0 );
228+
y = stdlib_base_dists_poisson_pmf( x, lambda );
229+
printf( "x: %d, λ: %.4f, P(X=x;λ): %.4f\n", x, lambda, y );
230+
}
231+
}
232+
```
233+
234+
</section>
235+
236+
<!-- /.examples -->
237+
238+
</section>
239+
240+
<!-- /.c -->
241+
143242
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
144243

145244
<section class="related">

0 commit comments

Comments
 (0)