Skip to content

Commit 3e84b59

Browse files
authored
docs: add missing README C documentation to stats/base/dists/pareto-type1
PR-URL: #11941 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 2df9472 commit 3e84b59

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

  • lib/node_modules/@stdlib/stats/base/dists/pareto-type1/pdf

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/pdf/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,105 @@ logEachMap( 'x: %0.4f, α: %0.4f, β: %0.4f, f(x;α,β): %0.4f', x, alpha, beta,
153153

154154
<!-- /.examples -->
155155

156+
<!-- C interface documentation. -->
157+
158+
* * *
159+
160+
<section class="c">
161+
162+
## C APIs
163+
164+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
165+
166+
<section class="intro">
167+
168+
</section>
169+
170+
<!-- /.intro -->
171+
172+
<!-- C usage documentation. -->
173+
174+
<section class="usage">
175+
176+
### Usage
177+
178+
```c
179+
#include "stdlib/stats/base/dists/pareto-type1/pdf.h"
180+
```
181+
182+
#### stdlib_base_dists_pareto_type1_pdf( x, alpha, beta )
183+
184+
Evaluates the probability density function (PDF) for a Pareto (Type I) distribution with shape parameter `alpha` and scale parameter `beta` at a value `x`.
185+
186+
```c
187+
double out = stdlib_base_dists_pareto_type1_pdf( 4.0, 1.0, 1.0 );
188+
// returns ~0.063
189+
```
190+
191+
The function accepts the following arguments:
192+
193+
- **x**: `[in] double` input value.
194+
- **alpha**: `[in] double` shape parameter.
195+
- **beta**: `[in] double` scale parameter.
196+
197+
```c
198+
double stdlib_base_dists_pareto_type1_pdf( const double x, const double alpha, const double beta );
199+
```
200+
201+
</section>
202+
203+
<!-- /.usage -->
204+
205+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
206+
207+
<section class="notes">
208+
209+
</section>
210+
211+
<!-- /.notes -->
212+
213+
<!-- C API usage examples. -->
214+
215+
<section class="examples">
216+
217+
### Examples
218+
219+
```c
220+
#include "stdlib/stats/base/dists/pareto-type1/pdf.h"
221+
#include "stdlib/constants/float64/eps.h"
222+
#include <stdlib.h>
223+
#include <stdio.h>
224+
225+
static double random_uniform( const double min, const double max ) {
226+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
227+
return min + ( v*(max-min) );
228+
}
229+
230+
int main( void ) {
231+
double alpha;
232+
double beta;
233+
double x;
234+
double y;
235+
int i;
236+
237+
for ( i = 0; i < 25; i++ ) {
238+
alpha = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
239+
beta = random_uniform( 1.0, 5.0 );
240+
x = random_uniform( beta, beta + 10.0 );
241+
y = stdlib_base_dists_pareto_type1_pdf( x, alpha, beta );
242+
printf( "x: %lf, α: %lf, β: %lf, f(x;α,β): %lf\n", x, alpha, beta, y );
243+
}
244+
}
245+
```
246+
247+
</section>
248+
249+
<!-- /.examples -->
250+
251+
</section>
252+
253+
<!-- /.c -->
254+
156255
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
157256

158257
<section class="related">

0 commit comments

Comments
 (0)