(z, sqrt2pi=(2.0*pi)**0.5)
| 1004 | |
| 1005 | |
| 1006 | def 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 | |
| 1024 | class TestDistributions(unittest.TestCase): |
| 1025 | def test_zeroinputs(self): |
no test coverage detected