You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var upperGammaFraction = require( './upper_gamma_fraction.js' );
730
723
731
724
732
-
// VARIABLES //
733
-
734
-
var MAX_FACTORIAL = 170; // TODO: consider extracting as a constant
735
-
736
-
737
725
// MAIN //
738
726
739
727
/**
740
728
* Computes the regularized incomplete gamma function. The upper tail is calculated via the modified Lentz's method for computing continued fractions, the lower tail using a power expansion.
741
729
*
742
730
* ## Notes
743
731
*
744
-
* - When `a >= MAX_FACTORIAL` and computing the non-normalized incomplete gamma, result is rather hard to compute unless we use logs. There are really two options a) if `x` is a long way from `a` in value then we can reliably use methods 2 and 4 below in logarithmic form and go straight to the result. Otherwise we let the regularized gamma take the strain (the result is unlikely to underflow in the central region anyway) and combine with `lgamma` in the hopes that we get a finite result.
732
+
* - When `a >= FLOAT64_MAX_SAFE_NTH_FACTORIAL` and computing the non-normalized incomplete gamma, result is rather hard to compute unless we use logs. There are really two options a) if `x` is a long way from `a` in value then we can reliably use methods 2 and 4 below in logarithmic form and go straight to the result. Otherwise we let the regularized gamma take the strain (the result is unlikely to underflow in the central region anyway) and combine with `lgamma` in the hopes that we get a finite result.
745
733
*
746
734
* @param {NonNegativeNumber} x - function parameter
if ( a >= MAX_FACTORIAL<spanclass="branch-0 cbranch-no" title="branch not covered" >&& !normalized </span>) <spanclass="branch-0 cbranch-no" title="branch not covered" >{</span>
763
+
if ( a >= FLOAT64_MAX_SAFE_NTH_FACTORIAL<spanclass="branch-0 cbranch-no" title="branch not covered" >&& !normalized </span>) <spanclass="branch-0 cbranch-no" title="branch not covered" >{</span>
776
764
<spanclass="cstat-no" title="statement not covered" > if ( invert && ( a * 4.0 < x ) ) {</span>
777
765
<spanclass="cstat-no" title="statement not covered" > // This is method 4 below, done in logs:</span>
778
766
<spanclass="cstat-no" title="statement not covered" > result = ( a * ln(x) ) - x;</span>
0 commit comments