X
4989

Calculating Incomplete Gamma Functions with IDL

 

Tolerance controls allow you to calculate the accuracy of the incomplete beta and gamma functions. (See the Help Article #3181 for calculating Incomplete Beta Functions.)

Working With Iteration Controls in the Incomplete Gamma Function. The following example shows how increasing the maximum number of iterations can change the outcome of computing the incomplete gamma function. Normally, the calculation of the incomplete gamma function will not converge within 100 iterations (the default number of iterations) when the parametric exponent is set to 400 and the upper limit is set to 400. The ITMAX keyword to the IGAMMA routine is set to 200 to allow the calculation to converge to a value of 0.506649 within 144 iterations.

More accuracy usually provides better results, but can cause slower computation speeds. If faster speeds are important, a less accurate calculation may be more desirable. This trade-off can be maintained through tolerances. Iteration controls allow you to expand the computation enough to converge to a result. Calculation of these functions may not converge to a result within the default number of iterations. If the number of iterations is increased, the calculation may converge.

Code Example:

PRO usingIGAMMAwithITMAX
 
    ; Define parametric exponent.
    parameterA = 400.

    ; Define the upper limit of integration.
    upperLimits = 400.

    ; NOTE: with the above parameter and limit, IGAMMA will
    ; not converge unless the number of iterations is
    ; increased above the default of 100.

    ; Compute the incomplete gamma function.
    gammaFunction = IGAMMA(parameterA, upperLimits, $
     ITMAX = 200, ITER = numberIteration)

    ; Output results.
    PRINT, 'Resulting Gamma Function: ', gammaFunction
    PRINT, 'Number of Iterations: ', numberIteration
 
END
_____________________________________________________
Reviewed by BC on 09/05/2014