specfun_gammainc — The incomplete gamma function.
y = specfun_gammainc ( x , a ) y = specfun_gammainc ( x , a , tail )
a matrix of doubles, the upper limit of integration of the gamma density. Must be real (not complex) and nonnegative.
a matrix of doubles, the shape parameter of the gamma density. Must be real (not complex) and nonnegative.
a 1 x 1 matrix of strings, the tail of the CDF function, "upper" or "lower" (default tail="lower"). Set tail="lower" to get the probability from the CDF gamma distribution function, set tail="upper" to get the complementary probability, that is q = 1-p.
a matrix of doubles, the incomplete gamma function.
Returns the incomplete gamma function. If tail="lower", the function definition is:
The tail option may be used to overcome the limitation of floating point arithmetic. If tail="upper", the function definition is:
We may use tail="upper" when the output of the gamminc function with tail="lower" is very close to 1.
If any of the input arguments a or x is a 1-by-1 matrix while the other one is a m-by-n matrix, then the 1-by-1 matrix is expanded to m-by-n. If the sizes of the two arguments do not match, we generate an error.
If a=0 and tail=="lower", we return y=1, whatever the value of x. If a=0 and tail=="upper", we return y=0, whatever the value of x.
specfun_gammainc(1,2) // Expected : 0.264241117657115 specfun_gammainc(2,3) // Expected : 0.323323583816936 specfun_gammainc(2,3,"lower") // Expected : 0.323323583816936 // We have specfun_gammainc(x,a,"lower") == 1 - specfun_gammainc(x,a,"upper") specfun_gammainc(2,3,"upper") // Expected : 0.676676416183064 // The following example shows how to use the tail argument. // For a=1 and x>40, the result is so close to 1 that the // result is represented by the floating point number y=1. specfun_gammainc(40,1) // Expected : 1 // This is why we may compute the complementary probability with // the tail option. specfun_gammainc(40,1,"upper") // Expected : 4.248354255291594e-018 // Show the expansion of a x = [1 2 3;4 5 6]; a = 2; specfun_gammainc(x,a)