Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var NINF = require( '@stdlib/constants/float64/ninf' );
* // returns ~-0.129
*/
function factory( mu, lambda ) {
var A;
if (
isnan( mu ) ||
isnan( lambda ) ||
Expand All @@ -58,6 +59,7 @@ function factory( mu, lambda ) {
if ( lambda === 0.0 ) {
return degenerate( mu );
}
A = ln( lambda ) - LN_TWO_PI;
return logpdf;

/**
Expand All @@ -79,8 +81,8 @@ function factory( mu, lambda ) {
if ( x <= 0.0 || x === PINF ) {
return NINF;
}
v = x - mu;
return 0.5 * ( ln( lambda ) - ( LN_TWO_PI + ( 3.0 * ln( x ) ) ) - ( ( lambda * v * v ) / ( mu * mu * x ) ) );
v = ( x - mu ) / mu;
Comment thread
Planeshifter marked this conversation as resolved.
return 0.5 * ( A - ( 3.0 * ln( x ) ) - ( ( ( lambda / x ) * v ) * v ) );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
if ( x <= 0.0 || x === PINF ) {
return NINF;
}
v = x - mu;
return 0.5 * ( ln( lambda ) - ( LN_TWO_PI + ( 3.0 * ln( x ) ) ) - ( ( lambda * v * v ) / ( mu * mu * x ) ) );
v = ( x - mu ) / mu;
return 0.5 * ( ln( lambda ) - ( LN_TWO_PI + ( 3.0 * ln( x ) ) ) - ( ( ( lambda / x ) * v ) * v ) );

Check warning on line 97 in lib/node_modules/@stdlib/stats/base/dists/wald/logpdf/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 103. Maximum allowed is 80
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ double stdlib_base_dists_wald_logpdf( const double x, const double mu, const dou
if ( x <= 0.0 || x == STDLIB_CONSTANT_FLOAT64_PINF ) {
return STDLIB_CONSTANT_FLOAT64_NINF;
}
v = x - mu;
return 0.5 * ( stdlib_base_ln( lambda ) - ( STDLIB_CONSTANT_FLOAT64_LN_TWO_PI + ( 3.0 * stdlib_base_ln( x ) ) ) - ( ( lambda * v * v ) / ( mu * mu * x ) ) );
v = ( x - mu ) / mu;
return 0.5 * ( stdlib_base_ln( lambda ) - ( STDLIB_CONSTANT_FLOAT64_LN_TWO_PI + ( 3.0 * stdlib_base_ln( x ) ) ) - ( ( ( lambda / x ) * v ) * v ) );
}