gamma¶
-
sherpa.utils.
gamma
(z)¶ Calculate the Gamma function.
Parameters: z (scalar or array) – -171 <= z <- 171.6 Returns: val Return type: scalar or array Notes
This implementation is provided by the Cephes Math Library [1]. Arguments
|x| >= 34
are reduced by recurrence and the function approximated by a rational function of degree 6/7 in the interval (2,3). Large arguments are handled by Stirling’s formula. Large negative arguments are made positive using a reflection formula. Relative errors aredomain # trials peak rms -170,33 20000 2.3e-15 3.3e-16 -33,33 20000 9.4e-16 2.2e-16 33,171.6 20000 2.3e-15 3.2e-16 Errors for arguments outside the test range will be larger owing to amplification by the exponential function.
References
[1] Cephes Math Library Release 2.0: April, 1987. Copyright 1985, 1987 by Stephen L. Moshier. Direct inquiries to 30 Frost Street, Cambridge, MA 02140. Examples
>>> gamma(2.3) 1.1667119051981603
>>> gamma([2.3,1.9]) array([ 1.16671191, 0.96176583])