(a, x, epsilon=3.e-7, iterations=700)
| 833 | |
| 834 | # Series approximation to the incomplete gamma function. |
| 835 | def gs(a, x, epsilon=3.e-7, iterations=700): |
| 836 | ln = gammaln(a) |
| 837 | s = 1.0 / a |
| 838 | d = 1.0 / a |
| 839 | for i in range(1, iterations): |
| 840 | d = d * x / (a + i) |
| 841 | s = s + d |
| 842 | if abs(d) < abs(s) * epsilon: |
| 843 | return (s * exp(-x + a * log(x) - ln), ln) |
| 844 | raise StopIteration, (abs(d), abs(s) * epsilon) |
| 845 | |
| 846 | # Continued fraction approximation of the incomplete gamma function. |
| 847 | def gf(a, x, epsilon=3.e-7, iterations=200): |