Skip to content

Commit 6b75679

Browse files
committed
Use constantFunction, consolidate conditionals, and add empty lines
1 parent a5d2e2c commit 6b75679

3 files changed

Lines changed: 14 additions & 27 deletions

File tree

lib/node_modules/@stdlib/math/base/dist/laplace/cdf/lib/cdf.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,43 @@ var exp = require( '@stdlib/math/base/special/exp' );
1919
* @example
2020
* var y = cdf( 2.0, 0.0, 1.0 );
2121
* // returns ~0.932
22+
*
2223
* @example
2324
* var y = cdf( 5.0, 10.0, 3.0 );
2425
* // returns ~0.094
26+
*
2527
* @example
2628
* var y = cdf( NaN, 0.0, 1.0 );
2729
* // returns NaN
30+
*
2831
* @example
2932
* var y = cdf( 2, NaN, 1.0 );
3033
* // returns NaN
34+
*
3135
* @example
3236
* var y = cdf( 2.0, 0.0, NaN );
3337
* // returns NaN
38+
*
3439
* @example
3540
* // Negative scale parameter:
3641
* var y = cdf( 2.0, 0.0, -1.0 );
3742
* // returns NaN
3843
*/
3944
function cdf( x, mu, b ) {
4045
var z;
41-
if ( isnan( x ) || isnan( mu ) || isnan( b ) ) {
42-
return NaN;
43-
}
44-
if ( b <= 0.0 ) {
46+
if (
47+
isnan( x ) ||
48+
isnan( mu ) ||
49+
isnan( b ) ||
50+
b <= 0.0
51+
) {
4552
return NaN;
4653
}
4754
z = ( x - mu ) / b;
4855
if ( x < mu ) {
4956
return 0.5 * exp( z );
5057
}
51-
return 1.0 - (0.5 * exp( -z ));
58+
return 1.0 - ( 0.5 * exp( -z ) );
5259
} // end FUNCTION cdf()
5360

5461

lib/node_modules/@stdlib/math/base/dist/laplace/cdf/lib/factory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
// MODULES //
44

5+
var constantFunction = require( '@stdlib/utils/constant-function' );
56
var isnan = require( '@stdlib/math/base/assert/is-nan' );
67
var exp = require( '@stdlib/math/base/special/exp' );
7-
var nan = require( './nan.js' );
88

99

1010
// MAIN //
@@ -31,7 +31,7 @@ function factory( mu, b ) {
3131
isnan( b ) ||
3232
b <= 0.0
3333
) {
34-
return nan;
34+
return constantFunction( NaN );
3535
}
3636
return cdf;
3737

lib/node_modules/@stdlib/math/base/dist/laplace/cdf/lib/nan.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)