File: test_gammainc.py

package info (click to toggle)
python-scipy 0.18.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 75,464 kB
  • ctags: 79,406
  • sloc: python: 143,495; cpp: 89,357; fortran: 81,650; ansic: 79,778; makefile: 364; sh: 265
file content (27 lines) | stat: -rw-r--r-- 798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from __future__ import division, print_function, absolute_import
import numpy as np
from scipy.special import gammainc
from scipy.special._testutils import FuncData


def test_line():
    # Test on the line a = x where a simpler asymptotic expansion
    # (analog of DLMF 8.12.15) is available.

    def gammainc_line(x):
        c = np.array([-1/3, -1/540, 25/6048, 101/155520, 
                      -3184811/3695155200, -2745493/8151736420])
        res = 0
        xfac = 1
        for ck in c:
            res -= ck*xfac
            xfac /= x
        res /= np.sqrt(2*np.pi*x)
        res += 0.5
        return res

    x = np.logspace(np.log10(25), 300, 500)
    a = x.copy()
    dataset = np.vstack((a, x, gammainc_line(x))).T

    FuncData(gammainc, dataset, (0, 1), 2, rtol=1e-11).check()