Skip to content

Commit 5ab3497

Browse files
authored
chore: update main.c
Signed-off-by: Philipp Burckhardt <[email protected]>
1 parent c5a88e1 commit 5ab3497

File tree

1 file changed

+18
-19
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/normal/logpdf/src

1 file changed

+18
-19
lines changed

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,33 @@
2727
/**
2828
* Evaluates the natural logarithm of the cumulative distribution function (CDF) for a Normal distribution with mean `mu` and standard deviation `sigma` at a value `x`.
2929
*
30-
* @param x input value
31-
* @param mu mean of the distribution
32-
* @param sigma standard deviation of the distribution
33-
* @return evaluated logarithm of probability density function
30+
* @param x input value
31+
* @param mu mean
32+
* @param sigma standard deviation
33+
* @return evaluated logarithm of probability density function
3434
*
3535
* @example
3636
* double y = stdlib_base_dists_normal_logpdf( 2.0, 0.0, 1.0 );
3737
* // returns ~-2.919
3838
*/
3939
double stdlib_base_dists_normal_logpdf( const double x, const double mu, const double sigma ) {
40-
41-
double s2;
42-
double A;
43-
double B;
40+
double s2;
41+
double A;
42+
double B;
4443

4544
if (
46-
stdlib_base_is_nan( x ) ||
47-
stdlib_base_is_nan( mu ) ||
48-
stdlib_base_is_nan( sigma ) ||
49-
sigma < 0.0
50-
) {
51-
return 0.0 / 0.0; // NaN
52-
}
45+
stdlib_base_is_nan( x ) ||
46+
stdlib_base_is_nan( mu ) ||
47+
stdlib_base_is_nan( sigma ) ||
48+
sigma < 0.0
49+
) {
50+
return 0.0 / 0.0; // NaN
51+
}
5352
if ( sigma == 0.0 ) {
5453
return (x == mu) ? STDLIB_CONSTANT_FLOAT64_PINF : STDLIB_CONSTANT_FLOAT64_NINF;
5554
}
56-
s2 = stdlib_base_pow(sigma, 2.0);
57-
A = (-0.5) * ( ( 2.0 * stdlib_base_ln(sigma) ) + STDLIB_CONSTANT_FLOAT64_LN_TWO_PI );
58-
B = -1.0 / ( 2.0 * s2 );
59-
return A + (B * stdlib_base_pow(x - mu, 2.0));
55+
s2 = stdlib_base_pow( sigma, 2.0 );
56+
A = (-0.5) * ( ( 2.0 * stdlib_base_ln(sigma) ) + STDLIB_CONSTANT_FLOAT64_LN_TWO_PI );
57+
B = -1.0 / ( 2.0 * s2 );
58+
return A + ( B * stdlib_base_pow( x - mu, 2.0 ) );
6059
}

0 commit comments

Comments
 (0)