File tree Expand file tree Collapse file tree
lib/node_modules/@stdlib/stats/base/dists/bernoulli/mgf/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121// MODULES //
2222
2323var constantFunction = require ( '@stdlib/utils/constant-function' ) ;
24- var isProbability = require ( '@stdlib/math/base/assert/is-probability' ) ;
2524var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
2625var exp = require ( '@stdlib/math/base/special/exp' ) ;
2726
@@ -40,7 +39,11 @@ var exp = require( '@stdlib/math/base/special/exp' );
4039* // returns ~0.855
4140*/
4241function factory ( p ) {
43- if ( ! isProbability ( p ) ) {
42+ if (
43+ isnan ( p ) ||
44+ p < 0.0 ||
45+ p > 1.0
46+ ) {
4447 return constantFunction ( NaN ) ;
4548 }
4649 return mgf ;
Original file line number Diff line number Diff line change 2020
2121// MODULES //
2222
23- var isProbability = require ( '@stdlib/math/base/assert/is-probability' ) ;
2423var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
2524var exp = require ( '@stdlib/math/base/special/exp' ) ;
2625
@@ -59,7 +58,12 @@ var exp = require( '@stdlib/math/base/special/exp' );
5958* // returns NaN
6059*/
6160function mgf ( t , p ) {
62- if ( isnan ( t ) || ! isProbability ( p ) ) {
61+ if (
62+ isnan ( t ) ||
63+ isnan ( p ) ||
64+ p < 0.0 ||
65+ p > 1.0
66+ ) {
6367 return NaN ;
6468 }
6569 return ( 1.0 - p ) + ( p * exp ( t ) ) ;
You can’t perform that action at this time.
0 commit comments