Skip to content

Commit b854d88

Browse files
committed
fix: change implementation to clear all test
1 parent c81fe33 commit b854d88

File tree

5 files changed

+9
-6029
lines changed

5 files changed

+9
-6029
lines changed

lib/node_modules/@stdlib/stats/base/dists/planck/pmf/lib/factory.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-int
2424
var constantFunction = require( '@stdlib/utils/constant-function' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var 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
}

lib/node_modules/@stdlib/stats/base/dists/planck/pmf/lib/main.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-integer' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var 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
*/
6263
function 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
}

0 commit comments

Comments
 (0)