Skip to content

Commit 5971a93

Browse files
committed
feat: add C implementation for stats/base/dists/frechet/logpdf: fix CodeReview comments
--- 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: passed - task: lint_c_examples status: na - 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 ed729a7 commit 5971a93

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

lib/node_modules/@stdlib/stats/base/dists/frechet/logpdf/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ for ( i = 0; i < 100; i++ ) {
199199

200200
#### stdlib_base_dists_frechet_logpdf( x, alpha, s, m )
201201

202-
Returns the the logarithm of probability density function for a Fréchet distribution with shape `alpha`, scale `s`, and location `m` at a value `x`.
202+
Evaluates the logarithm of the [probability density function][pdf] (PDF) for a [Fréchet][frechet-distribution] distribution with shape `alpha`, scale `s`, and location `m` at a value `x`.
203203

204204
```c
205205
double y = stdlib_base_dists_frechet_logpdf( 10.0, 2.0, 3.0, 2.0 );
@@ -247,16 +247,16 @@ static double random_uniform( const double min, const double max ) {
247247
}
248248
249249
int main( void ) {
250-
double x;
251250
double alpha;
251+
double x;
252252
double s;
253253
double m;
254254
double y;
255255
int i;
256256
257257
for ( i = 0; i < 10; i++ ) {
258-
x = random_uniform( 0.0, 10.0 );
259258
alpha = random_uniform( 0.0, 10.0 );
259+
x = random_uniform( 0.0, 10.0 );
260260
s = random_uniform( 0.0, 10.0 );
261261
m = random_uniform( 0.0, 10.0 );
262262
y = stdlib_base_dists_frechet_logpdf( x, alpha, s, m );

lib/node_modules/@stdlib/stats/base/dists/frechet/logpdf/benchmark/c/benchmark.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ static double random_uniform( const double min, const double max ) {
9393
* @return elapsed time in seconds
9494
*/
9595
static double benchmark( void ) {
96-
double elapsed;
97-
double x [ 100 ];
9896
double alpha[ 100 ];
99-
double s[ 100 ];
10097
double m[ 100 ];
98+
double x[ 100 ];
99+
double s[ 100 ];
100+
double elapsed;
101101
double y;
102102
double t;
103103
int i;
@@ -106,7 +106,7 @@ static double benchmark( void ) {
106106
x[ i ] = random_uniform( -50.0, 50.0 );
107107
alpha[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 );
108108
s[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 );
109-
m[ i ] = random_uniform( -20.0, 20.0 );
109+
m[ i ] = random_uniform( -20.0, 40.0 );
110110
}
111111

112112
t = tic();

lib/node_modules/@stdlib/stats/base/dists/frechet/logpdf/manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@
8282
"@stdlib/math/base/special/pow",
8383
"@stdlib/math/base/special/ln",
8484
"@stdlib/constants/float64/ninf",
85-
"@stdlib/constants/float64/nan",
86-
"@stdlib/constants/float64/eps"
85+
"@stdlib/constants/float64/nan"
8786
]
8887
}
8988
]

lib/node_modules/@stdlib/stats/base/dists/frechet/logpdf/src/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
#include "stdlib/constants/float64/nan.h"
2525

2626
/**
27-
* Returns the logpdf for a Fréchet distribution with shape `alpha`, scale `s`, and location `m` at a value `x`.
27+
* Evaluates the logarithm of the probability density function (PDF) for a Fréchet distribution with shape `alpha`, scale `s`, and location `m` at a value `x`.
2828
*
29-
* @param x x parameter
29+
* @param x input value
3030
* @param alpha shape parameter
3131
* @param s scale parameter
3232
* @param m location parameter
33-
* @return logpdf
33+
* @return evaluated logPDF
3434
*
3535
* @example
3636
* double y = stdlib_base_dists_frechet_logpdf( 10.0, 2.0, 3.0, 2.0 );
@@ -52,5 +52,5 @@ double stdlib_base_dists_frechet_logpdf( const double x, const double alpha, con
5252
return STDLIB_CONSTANT_FLOAT64_NINF;
5353
}
5454
z = ( x - m ) / s;
55-
return stdlib_base_ln( alpha/s ) - ( 1.0+alpha ) * stdlib_base_ln( z ) - stdlib_base_pow( z, -alpha );
55+
return stdlib_base_ln( alpha/s ) - ( ( 1.0+alpha ) * stdlib_base_ln( z ) ) - stdlib_base_pow( z, -alpha );
5656
}

0 commit comments

Comments
 (0)