File tree Expand file tree Collapse file tree
lib/node_modules/@stdlib/math/base/dist/laplace/cdf/lib Expand file tree Collapse file tree Original file line number Diff line number Diff 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*/
3944function 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
Original file line number Diff line number Diff line change 22
33// MODULES //
44
5+ var constantFunction = require ( '@stdlib/utils/constant-function' ) ;
56var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
67var 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
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments