Skip to content

Commit 7fcf43f

Browse files
committed
fix: apply standard C implementation fixes to pareto-type1/logpdf
--- 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: na - 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 2d775cc commit 7fcf43f

File tree

6 files changed

+27
-61
lines changed

6 files changed

+27
-61
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ for ( i = 0; i < 10; i++ ) {
194194

195195
#### stdlib_base_dists_pareto_type1_logpdf( x, alpha, beta )
196196

197-
Returns the logpdf of a Pareto (Type I) distribution.
197+
Evaluates the natural logarithm of the probability density function (PDF) for a Pareto (Type I) distribution with parameters `alpha` (shape parameter) and `beta` (scale parameter).
198198

199199
```c
200200
double y = stdlib_base_dists_pareto_type1_logpdf( 4.0, 1.0, 1.0 );
@@ -203,9 +203,9 @@ double y = stdlib_base_dists_pareto_type1_logpdf( 4.0, 1.0, 1.0 );
203203

204204
The function accepts the following arguments:
205205

206-
- **x**: `[in] double` first shape parameter.
207-
- **alpha**: `[in] double` second shape parameter.
208-
- **beta**: `[in] double` third shape parameter.
206+
- **x**: `[in] double` input value.
207+
- **alpha**: `[in] double` shape parameter.
208+
- **beta**: `[in] double` scale parameter.
209209

210210
```c
211211
double stdlib_base_dists_pareto_type1_logpdf( const double x, const double alpha, const double beta );
@@ -219,27 +219,32 @@ double stdlib_base_dists_pareto_type1_logpdf( const double x, const double alpha
219219
<!-- /.notes -->
220220
<!-- C API usage examples. -->
221221
<section class="examples">
222+
222223
### Examples
224+
223225
```c
224226
#include "stdlib/stats/base/dists/pareto-type1/logpdf.h"
225227
#include <stdlib.h>
226228
#include <stdio.h>
229+
227230
static double random_uniform( const double min, const double max ) {
228231
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
229232
return min + ( v*(max-min) );
230233
}
234+
231235
int main( void ) {
232236
double alpha;
233237
double beta;
234238
double x;
235239
double y;
236240
int i;
241+
237242
for ( i = 0; i < 25; i++ ) {
238-
alpha = random_uniform( 0, 10 ) + 3.0;
239-
beta = random_uniform( 0, 10 );
240-
x = random_uniform( 0, 10 );
243+
alpha = random_uniform( 0.1, 5.0 );
244+
beta = random_uniform( alpha, alpha + 5.0 );
245+
x = random_uniform( beta, beta + 10.0 );
241246
y = stdlib_base_dists_pareto_type1_logpdf( x, alpha, beta );
242-
printf( "x: %lf, α: %lf, β: %lf, logpdf(X,α,β): %lf\n", x, alpha, beta, y );
247+
printf( "x: %lf, α: %lf, β: %lf, ln(f(x;α,β)): %lf\n", x, alpha, beta, y );
243248
}
244249
}
245250
```

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/benchmark/benchmark.native.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
2626
var tryRequire = require( '@stdlib/utils/try-require' );
27-
var randu = require( '@stdlib/random/base/randu' );
27+
var uniform = require( '@stdlib/random/base/uniform' );
2828
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2929
var EPS = require( '@stdlib/constants/float64/eps' );
3030
var pkg = require( './../package.json' ).name;
@@ -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-
x[ i ] = ( randu() * 10.0 ) + 3.0 + EPS;
57-
alpha[ i ] = ( randu() * 10.0 ) + 3.0 + EPS;
58-
beta[ i ] = ( randu() * 10.0 ) + EPS;
56+
alpha[ i ] = uniform( EPS, 100.0 );
57+
beta[ i ] = uniform( 3.0 + EPS, 100.0 );
58+
x[ i ] = uniform( EPS, 20.0 );
5959
}
6060

6161
b.tic();

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/examples/c/example.c

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

3535
for ( i = 0; i < 25; i++ ) {
36-
x = random_uniform( 0, 1 );
37-
alpha = random_uniform( 0, 10 ) + 3.0;
38-
beta = random_uniform( 0, 10 );
36+
x = random_uniform( 0.1, 10.0 );
37+
alpha = random_uniform( 0.1, 5.0 );
38+
beta = random_uniform( alpha, alpha + 5.0 );
3939
y = stdlib_base_dists_pareto_type1_logpdf( x, alpha, beta );
40-
printf( "x: %lf, α: %lf, β: %lf, logpdf(X;α,β): %lf\n", x, alpha, beta, y );
40+
printf( "x: %lf, α: %lf, β: %lf, ln(f(x;α,β)): %lf\n", x, alpha, beta, y );
4141
}
4242
}

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/include/stdlib/stats/base/dists/pareto-type1/logpdf.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 logpdf of a Pareto (Type I) distribution.
30+
* Evaluates the logpdf of a Pareto (Type I) distribution.
3131
*/
3232
double stdlib_base_dists_pareto_type1_logpdf( const double x, const double alpha, const double beta );
3333

lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/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 natural logarithm of the probability density function (PDF) for a Pareto (Type I) 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/pareto-type1/logpdf/src/main.c

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -27,54 +27,14 @@
2727
/**
2828
* Evaluates the natural logarithm of the probability density function (PDF) for a Pareto (Type I) distribution with shape parameter `alpha` and scale parameter `beta` at a value `x`.
2929
*
30-
* @param {number} x - input value
31-
* @param {PositiveNumber} alpha - shape parameter
32-
* @param {PositiveNumber} beta - scale parameter
33-
* @returns {number} evaluated logPDF
30+
* @param x input value
31+
* @param alpha shape parameter
32+
* @param beta scale parameter
33+
* @return evaluated logPDF
3434
*
3535
* @example
3636
* double y = stdlib_base_dists_pareto_type1_logpdf( 4.0, 1.0, 1.0 );
3737
* // returns ~-2.773
38-
*
39-
* @example
40-
* double y = stdlib_base_dists_pareto_type1_logpdf( 20.0, 1.0, 10.0 );
41-
* // returns ~-3.689
42-
*
43-
* @example
44-
* double y = stdlib_base_dists_pareto_type1_logpdf( 7.0, 2.0, 6.0 );
45-
* // returns ~-1.561
46-
*
47-
* @example
48-
* double y = stdlib_base_dists_pareto_type1_logpdf( 7.0, 6.0, 3.0 );
49-
* // returns ~-5.238
50-
*
51-
* @example
52-
* double y = stdlib_base_dists_pareto_type1_logpdf( 1.0, 4.0, 2.0 );
53-
* // returns -Infinity
54-
*
55-
* @example
56-
* double y = stdlib_base_dists_pareto_type1_logpdf( 1.5, 4.0, 2.0 );
57-
* // returns -Infinity
58-
*
59-
* @example
60-
* double y = stdlib_base_dists_pareto_type1_logpdf( 0.5, -1.0, 0.5 );
61-
* // returns NaN
62-
*
63-
* @example
64-
* double y = stdlib_base_dists_pareto_type1_logpdf( 0.5, 0.5, -1.0 );
65-
* // returns NaN
66-
*
67-
* @example
68-
* double y = stdlib_base_dists_pareto_type1_logpdf( NaN, 1.0, 1.0 );
69-
* // returns NaN
70-
*
71-
* @example
72-
* double y = stdlib_base_dists_pareto_type1_logpdf( 0.5, NaN, 1.0 );
73-
* // returns NaN
74-
*
75-
* @example
76-
* double y = stdlib_base_dists_pareto_type1_logpdf( 0.5, 1.0, NaN );
77-
* // returns NaN
7838
*/
7939
double stdlib_base_dists_pareto_type1_logpdf( const double x, const double alpha, const double beta ) {
8040
double denom;

0 commit comments

Comments
 (0)