def test_nu_varying_gamma_mod(s, nu, N, h):
    ht = HankelTransform(nu=nu, N=N, h=h)

    ans = ht.integrate(lambda x: x ** (nu - 2 * s + 1) * gammainc_(s, x ** 2), False, False)
    anl = 0.5 ** (2 * s - nu - 1) * gammaincc_(1 - s + nu, 0.25)

    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
Esempio n. 2
0
def test_nu_varying_powerlaw(s, nu, N, h):
    ht = HankelTransform(nu=nu, N=N, h=h)

    ans = ht.integrate(lambda x: x**(s + 1), False, False)
    anl = 2**(s + 1) * gamma(0.5 * (2 + nu + s)) / gamma(0.5 * (nu - s))

    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
def test_nu0_x4():
    """
    Result on wikipedia
    """
    ht = HankelTransform(nu=0, N=150, h=10 ** -1.5)
    ans = ht.integrate(lambda x: x ** 4, False, False)
    print("Numerical Result: ", ans, " (required 9)")
    assert np.isclose(ans, 9, rtol=1e-3)
Esempio n. 4
0
def test_nu0_x4():
    """
    Result on wikipedia
    """
    ht = HankelTransform(nu=0, N=150, h=10**-1.5)
    ans = ht.integrate(lambda x: x**4, False, False)
    print("Numerical Result: ", ans, " (required 9)")
    assert np.isclose(ans, 9, rtol=1e-3)
def test_nu_varying_powerlaw(s, nu, N, h):
    ht = HankelTransform(nu=nu, N=N, h=h)

    ans = ht.integrate(lambda x: x ** (s + 1), False, False)
    anl = 2 ** (s + 1) * gamma(0.5 * (2 + nu + s)) / gamma(0.5 * (nu - s))

    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
Esempio n. 6
0
def test_nu_varying_gamma_mod(s, nu, N, h):
    ht = HankelTransform(nu=nu, N=N, h=h)

    ans = ht.integrate(lambda x: x**(nu - 2 * s + 1) * gammainc_(s, x**2),
                       False, False)
    anl = 0.5**(2 * s - nu - 1) * gammaincc_(1 - s + nu, 0.25)

    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
Esempio n. 7
0
def test_nu0_f_gauss():
    """
    Result on wikipedia
    """
    z = 2
    ht = HankelTransform(nu=0, N=50, h=0.01)

    ans = ht.integrate(lambda x: x * np.exp(-0.5 * z**2 * x**2), False, False)
    anl = 1.0 / z**2 * np.exp(-0.5 / z**2)
    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
def test_nu0_f_gauss():
    """
    Result on wikipedia
    """
    z = 2
    ht = HankelTransform(nu=0, N=50, h=0.01)

    ans = ht.integrate(lambda x: x * np.exp(-0.5 * z ** 2 * x ** 2), False, False)
    anl = 1. / z ** 2 * np.exp(-0.5 / z ** 2)
    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
def test_nu0_f_x2():
    """
    Test f(x) = x^2, nu=0

    Result on wikipedia
    """
    ht = HankelTransform(nu=0, N=100, h=10 ** -1.5)

    ans = ht.integrate(lambda x: x ** 2, False, False)
    print("Numerical Result: ", ans, " (required -1)")
    assert np.isclose(ans, -1, rtol=1e-3)
Esempio n. 10
0
def test_nu0_f_x_on_x2():
    """
    Test f(x) = x/(x**2 + 1), nu=0

    This test is done in the Ogata (2005) paper, section 5"
    """
    ht = HankelTransform(nu=0, N=50, h=10 ** -1.5)

    ans = ht.integrate(lambda x: x / (x ** 2 + 1), False, False)
    print("Numerical Result: ", ans, " (required %s)" % k0(1))
    assert np.isclose(ans, k0(1), rtol=1e-3)
Esempio n. 11
0
def test_nu0_f_unity():
    """
    Test f(x) = 1, nu=0

    This test is done in the Ogata (2005) paper, section 5"
    """

    ht = HankelTransform(nu=0, N=50, h=0.1)
    ans = ht.integrate(lambda x: 1, False, False)
    print("Numerical Result: ", ans, " (required %s)" % 1)
    assert np.isclose(ans, 1, rtol=1e-3)
Esempio n. 12
0
def test_nu0_f_unity():
    """
    Test f(x) = 1, nu=0

    This test is done in the Ogata (2005) paper, section 5"
    """

    ht = HankelTransform(nu=0, N=50, h=0.1)
    ans = ht.integrate(lambda x: 1, False, False)
    print("Numerical Result: ", ans, " (required %s)" % 1)
    assert np.isclose(ans, 1, rtol=1e-3)
Esempio n. 13
0
def test_nu0_f_x_on_x2():
    """
    Test f(x) = x/(x**2 + 1), nu=0

    This test is done in the Ogata (2005) paper, section 5"
    """
    ht = HankelTransform(nu=0, N=50, h=10**-1.5)

    ans = ht.integrate(lambda x: x / (x**2 + 1), False, False)
    print("Numerical Result: ", ans, " (required %s)" % k0(1))
    assert np.isclose(ans, k0(1), rtol=1e-3)
Esempio n. 14
0
def test_nu0_f_x2():
    """
    Test f(x) = x^2, nu=0

    Result on wikipedia
    """
    ht = HankelTransform(nu=0, N=100, h=10**-1.5)

    ans = ht.integrate(lambda x: x**2, False, False)
    print("Numerical Result: ", ans, " (required -1)")
    assert np.isclose(ans, -1, rtol=1e-3)
Esempio n. 15
0
def test_nu0_x_on_sqrt_x2_pz2():
    """
    Result on wikipedia
    """
    # Note that the number required is highly dependent on z .... smaller z is harder.
    ht = HankelTransform(nu=0, N=50, h=10**-1.3)

    z = 1
    ans = ht.integrate(lambda x: x / np.sqrt(x**2 + z**2), False, False)
    anl = np.exp(-z)
    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
Esempio n. 16
0
def test_nu0_1_on_sqrt_x():
    """
    Result on wikipedia
    """
    # NOTE: this is REALLY finnicky!! (check devel/)
    ht = HankelTransform(nu=0, N=160, h=10**-3.5)
    ans = ht.integrate(lambda x: 1.0 / np.sqrt(x), False, False)
    m = -1.5
    anl = 2**(m + 1) * gamma(m / 2 + 1) / gamma(-m / 2)

    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
Esempio n. 17
0
def test_nu0_1_on_sqrt_x():
    """
    Result on wikipedia
    """
    # NOTE: this is REALLY finnicky!! (check devel/)
    ht = HankelTransform(nu=0, N=160, h=10 ** -3.5)
    ans = ht.integrate(lambda x: 1. / np.sqrt(x), False, False)
    m = -1.5
    anl = 2 ** (m + 1) * gamma(m / 2 + 1) / gamma(-m / 2)

    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
Esempio n. 18
0
def test_nu0_x_on_sqrt_x2_pz2():
    """
    Result on wikipedia
    """
    # Note that the number required is highly dependent on z .... smaller z is harder.
    ht = HankelTransform(nu=0, N=50, h=10 ** -1.3)

    z = 1
    ans = ht.integrate(lambda x: x / np.sqrt(x ** 2 + z ** 2), False, False)
    anl = np.exp(-z)
    print("Numerical Result: ", ans, " (required %s)" % anl)
    assert np.isclose(ans, anl, rtol=1e-3)
Esempio n. 19
0
def test_equivalence_of_integrate_and_transform():
    ht = HankelTransform(N=50)
    intg = ht.integrate(lambda x: 1, False)
    tr = ht.transform(lambda x: 1.0 / x, ret_err=False)
    assert intg == tr
Esempio n. 20
0
def test_ret_err_and_cumsum():
    ht = HankelTransform(N=50)
    res, err, cumsum = ht.integrate(lambda x: 1.0 / x, True, True)
Esempio n. 21
0
def test_ret_cumsum():
    ht = HankelTransform(N=50)
    res, cumsum = ht.integrate(lambda x: 1.0 / x, False, True)
Esempio n. 22
0
def test_ret_err():
    ht = HankelTransform(N=50)
    res, err = ht.integrate(lambda x: 1.0 / x, True)
Esempio n. 23
0
def test_equivalence_of_integrate_and_transform():
    ht = HankelTransform(N=50)
    int = ht.integrate(lambda x: 1, False)
    tr = ht.transform(lambda x: 1. / x, ret_err=False)
    assert int == tr
Esempio n. 24
0
def test_ret_err_and_cumsum():
    ht = HankelTransform(N=50)
    res, err, cumsum = ht.integrate(lambda x: 1. / x, True, True)
Esempio n. 25
0
def test_ret_cumsum():
    ht = HankelTransform(N=50)
    res, cumsum = ht.integrate(lambda x: 1. / x, False, True)
Esempio n. 26
0
def test_ret_err():
    ht = HankelTransform(N=50)
    res, err = ht.integrate(lambda x: 1. / x, True)