MCPcopy Index your code
hub / github.com/RustPython/RustPython / gamma

Function gamma

Lib/test/test_random.py:1006–1022  ·  view source on GitHub ↗
(z, sqrt2pi=(2.0*pi)**0.5)

Source from the content-addressed store, hash-verified

1004
1005
1006def gamma(z, sqrt2pi=(2.0*pi)**0.5):
1007 # Reflection to right half of complex plane
1008 if z < 0.5:
1009 return pi / sin(pi*z) / gamma(1.0-z)
1010 # Lanczos approximation with g=7
1011 az = z + (7.0 - 0.5)
1012 return az ** (z-0.5) / exp(az) * sqrt2pi * fsum([
1013 0.9999999999995183,
1014 676.5203681218835 / z,
1015 -1259.139216722289 / (z+1.0),
1016 771.3234287757674 / (z+2.0),
1017 -176.6150291498386 / (z+3.0),
1018 12.50734324009056 / (z+4.0),
1019 -0.1385710331296526 / (z+5.0),
1020 0.9934937113930748e-05 / (z+6.0),
1021 0.1659470187408462e-06 / (z+7.0),
1022 ])
1023
1024class TestDistributions(unittest.TestCase):
1025 def test_zeroinputs(self):

Callers 1

test_avg_stdMethod · 0.70

Calls 3

sinFunction · 0.90
expFunction · 0.90
fsumFunction · 0.90

Tested by

no test coverage detected