Skip to content

Commit a0852a4

Browse files
committed
chore: minor clean-up
--- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent df47978 commit a0852a4

File tree

7 files changed

+116
-46
lines changed

7 files changed

+116
-46
lines changed

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

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,105 @@ for ( i = 0; i < 10; i++ ) {
145145

146146
<!-- /.examples -->
147147

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

150249
<section class="related">

lib/node_modules/@stdlib/stats/base/dists/invgamma/pdf/benchmark/benchmark.native.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var tryRequire = require( '@stdlib/utils/try-require' );
26-
var randu = require( '@stdlib/random/base/randu' );
26+
var uniform = require( '@stdlib/random/base/uniform' );
2727
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2828
var Float64Array = require( '@stdlib/array/float64' );
2929
var EPS = require( '@stdlib/constants/float64/eps' );
@@ -53,9 +53,9 @@ bench( pkg, opts, function benchmark( b ) {
5353
beta = new Float64Array( len );
5454
x = new Float64Array( len );
5555
for ( i = 0; i < len; i++ ) {
56-
alpha[ i ] = ( randu()*10.0 ) + 4.0 + EPS;
57-
beta[ i ] = ( randu()*10.0 ) + EPS;
58-
x[ i ] = ( randu()*10.0 ) + EPS;
56+
alpha[ i ] = uniform( EPS, 10.0 );
57+
beta[ i ] = uniform( EPS, 10.0 );
58+
x[ i ] = uniform( EPS, 10.0 );
5959
}
6060

6161
b.tic();

lib/node_modules/@stdlib/stats/base/dists/invgamma/pdf/benchmark/c/benchmark.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ static double benchmark( void ) {
102102
int i;
103103

104104
for ( i = 0; i < 100; i++ ) {
105-
x[ i ] = random_uniform( 0.0, 10.0 ) + 4.0 + STDLIB_CONSTANT_FLOAT64_EPS;
106-
alpha[ i ] = random_uniform( 0.0, 10.0 ) + 4.0 + STDLIB_CONSTANT_FLOAT64_EPS;
107-
beta[ i ] = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
105+
x[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
106+
alpha[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
107+
beta[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
108108
}
109109

110110
t = tic();

lib/node_modules/@stdlib/stats/base/dists/invgamma/pdf/examples/c/example.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ int main( void ) {
3434
int i;
3535

3636
for ( i = 0; i < 25; i++ ) {
37-
alpha = random_uniform( 0.0, 5.0 );
38-
beta = random_uniform( 0.0, 5.0 );
3937
x = random_uniform( 0.0, 2.0 );
38+
alpha = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
39+
beta = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 );
4040
y = stdlib_base_dists_invgamma_pdf( x, alpha, beta );
41-
printf( "x: %lf, α: %lf, β: %lf, Pdf(X;x,α,β): %lf\n", x, alpha, beta, y );
41+
printf( "x: %lf, α: %lf, β: %lf, f(x;α,β): %lf\n", x, alpha, beta, y );
4242
}
4343
}

lib/node_modules/@stdlib/stats/base/dists/invgamma/pdf/include/stdlib/stats/base/dists/invgamma/pdf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Returns the probability density function (PDF) for an inverse gamma distribution with shape parameter `alpha` and scale parameter `beta` at a value `x`.
30+
* Evaluates the probability density function (PDF) for an inverse gamma distribution.
3131
*/
3232
double stdlib_base_dists_invgamma_pdf( const double x, const double alpha, const double beta );
3333

lib/node_modules/@stdlib/stats/base/dists/invgamma/pdf/lib/native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var addon = require( './../src/addon.node' );
2828
/**
2929
* Evaluates the probability density function (PDF) for an inverse gamma distribution with shape parameter `alpha` and scale parameter `beta` at a value `x`.
3030
*
31+
* @private
3132
* @param {number} x - input value
3233
* @param {PositiveNumber} alpha - shape parameter
3334
* @param {PositiveNumber} beta - scale parameter

lib/node_modules/@stdlib/stats/base/dists/invgamma/pdf/src/main.c

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,16 @@
2323
#include "stdlib/math/base/special/ln.h"
2424

2525
/**
26-
* Returns the probability density function (PDF) for an inverse gamma distribution with shape parameter `alpha` and scale parameter `beta` at a value `x`.
26+
* Evaluates the probability density function (PDF) for an inverse gamma distribution with shape parameter `alpha` and scale parameter `beta` at a value `x`.
2727
*
28-
* @param {number} x - input value
29-
* @param {PositiveNumber} alpha - shape parameter
30-
* @param {PositiveNumber} beta - scale parameter
31-
* @returns {number} evaluated PDF
28+
* @param x input value
29+
* @param alpha shape parameter
30+
* @param beta scale parameter
31+
* @return evaluated PDF
3232
*
3333
* @example
3434
* double y = stdlib_base_dists_invgamma_pdf( 2.0, 0.5, 1.0 );
3535
* // returns ~0.121
36-
*
37-
* @example
38-
* double y = stdlib_base_dists_invgamma_pdf( 0.2, 1.0, 1.0 );
39-
* // returns ~0.168
40-
*
41-
* @example
42-
* double y = stdlib_base_dists_invgamma_pdf( -1.0, 4.0, 2.0 );
43-
* // returns 0.0
44-
*
45-
* @example
46-
* double y = stdlib_base_dists_invgamma_pdf( NaN, 1.0, 1.0 );
47-
* // returns NaN
48-
*
49-
* @example
50-
* double y = stdlib_base_dists_invgamma_pdf( 0.0, NaN, 1.0 );
51-
* // returns NaN
52-
*
53-
* @example
54-
* double y = stdlib_base_dists_invgamma_pdf( 0.0, 1.0, NaN );
55-
* // returns NaN
56-
*
57-
* @example
58-
* // Negative shape parameter:
59-
* double y = stdlib_base_dists_invgamma_pdf( 2.0, -1.0, 1.0 );
60-
* // returns NaN
61-
*
62-
* @example
63-
* // Negative scale parameter:
64-
* double y = stdlib_base_dists_invgamma_pdf( 2.0, 1.0, -1.0 );
65-
* // returns NaN
6636
*/
6737
double stdlib_base_dists_invgamma_pdf( const double x, const double alpha, const double beta ) {
6838
double lnl;

0 commit comments

Comments
 (0)