File tree Expand file tree Collapse file tree 5 files changed +9
-6029
lines changed
lib/node_modules/@stdlib/stats/base/dists/planck/pmf Expand file tree Collapse file tree 5 files changed +9
-6029
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ var isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-int
2424var constantFunction = require ( '@stdlib/utils/constant-function' ) ;
2525var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
2626var exp = require ( '@stdlib/math/base/special/exp' ) ;
27+ var expm1 = require ( '@stdlib/math/base/special/expm1' ) ;
2728
2829
2930// MAIN //
@@ -60,15 +61,11 @@ function factory( lambda ) {
6061 * // returns <number>
6162 */
6263 function pmf ( x ) {
63- var temp1 ;
64- var temp2 ;
6564 if ( isnan ( x ) ) {
6665 return NaN ;
6766 }
6867 if ( isNonNegativeInteger ( x ) ) {
69- temp1 = exp ( - lambda ) ;
70- temp2 = exp ( - lambda * x ) ;
71- return ( 1 - temp1 ) * temp2 ;
68+ return - expm1 ( - lambda ) * exp ( - lambda * x ) ;
7269 }
7370 return 0.0 ;
7471 }
Original file line number Diff line number Diff line change 2323var isNonNegativeInteger = require ( '@stdlib/math/base/assert/is-nonnegative-integer' ) ;
2424var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
2525var exp = require ( '@stdlib/math/base/special/exp' ) ;
26+ var expm1 = require ( '@stdlib/math/base/special/expm1' ) ;
2627
2728
2829// MAIN //
@@ -60,15 +61,11 @@ var exp = require( '@stdlib/math/base/special/exp' );
6061* // returns NaN
6162*/
6263function pmf ( x , lambda ) {
63- var temp1 ;
64- var temp2 ;
6564 if ( isnan ( x ) || isnan ( lambda ) || lambda < 0.0 ) {
6665 return NaN ;
6766 }
6867 if ( isNonNegativeInteger ( x ) ) {
69- temp1 = exp ( - lambda ) ;
70- temp2 = exp ( - lambda * x ) ;
71- return ( 1 - temp1 ) * temp2 ;
68+ return - expm1 ( - lambda ) * exp ( - lambda * x ) ;
7269 }
7370 return 0.0 ;
7471}
You can’t perform that action at this time.
0 commit comments