예제 #1
0
def test_he_roots():
    verify_gauss_quad(orth.he_roots, orth.eval_hermitenorm, 5)
    verify_gauss_quad(orth.he_roots, orth.eval_hermitenorm, 25, atol=1e-13)
    verify_gauss_quad(orth.he_roots, orth.eval_hermitenorm, 100, atol=1e-12)

    x, w = orth.he_roots(5, False)
    y, v, m = orth.he_roots(5, True)
    assert_allclose(x, y, 1e-14, 1e-14)
    assert_allclose(w, v, 1e-14, 1e-14)

    assert_raises(ValueError, orth.he_roots, 0)
    assert_raises(ValueError, orth.he_roots, 3.3)
예제 #2
0
def test_he_roots():
    verify_gauss_quad(orth.he_roots, orth.eval_hermitenorm, 5)
    verify_gauss_quad(orth.he_roots, orth.eval_hermitenorm, 25, atol=1e-13)
    verify_gauss_quad(orth.he_roots, orth.eval_hermitenorm, 100, atol=1e-12)

    x, w = orth.he_roots(5, False)
    y, v, m = orth.he_roots(5, True)
    assert_allclose(x, y, 1e-14, 1e-14)
    assert_allclose(w, v, 1e-14, 1e-14)

    assert_raises(ValueError, orth.he_roots, 0)
    assert_raises(ValueError, orth.he_roots, 3.3)
예제 #3
0
def test_he_roots():
    rootf = orth.he_roots
    evalf = orth.eval_hermitenorm
    weightf = orth.hermitenorm(5).weight_func

    verify_gauss_quad(rootf, evalf, weightf, -np.inf, np.inf, 5)
    verify_gauss_quad(rootf, evalf, weightf, -np.inf, np.inf, 25, atol=1e-13)
    verify_gauss_quad(rootf, evalf, weightf, -np.inf, np.inf, 100, atol=1e-12)

    x, w = orth.he_roots(5, False)
    y, v, m = orth.he_roots(5, True)
    assert_allclose(x, y, 1e-14, 1e-14)
    assert_allclose(w, v, 1e-14, 1e-14)

    muI, muI_err = integrate.quad(weightf, -np.inf, np.inf)
    assert_allclose(m, muI, rtol=muI_err)

    assert_raises(ValueError, orth.he_roots, 0)
    assert_raises(ValueError, orth.he_roots, 3.3)
예제 #4
0
def test_he_roots():
    rootf = orth.he_roots
    evalf = orth.eval_hermitenorm
    weightf = orth.hermitenorm(5).weight_func

    verify_gauss_quad(rootf, evalf, weightf, -np.inf, np.inf, 5)
    verify_gauss_quad(rootf, evalf, weightf, -np.inf, np.inf, 25, atol=1e-13)
    verify_gauss_quad(rootf, evalf, weightf, -np.inf, np.inf, 100, atol=1e-12)

    x, w = orth.he_roots(5, False)
    y, v, m = orth.he_roots(5, True)
    assert_allclose(x, y, 1e-14, 1e-14)
    assert_allclose(w, v, 1e-14, 1e-14)

    muI, muI_err = integrate.quad(weightf, -np.inf, np.inf)
    assert_allclose(m, muI, rtol=muI_err)

    assert_raises(ValueError, orth.he_roots, 0)
    assert_raises(ValueError, orth.he_roots, 3.3)
예제 #5
0
파일: markov.py 프로젝트: jrnold/psc585
def qnwnorm1(n):
    """Gauss-Hermite normal quadrature nodes and weights in 1 dimension

    Parameters
    ------------
    n : int
        Number of quadrature nodes

    Returns
    ----------
    x : (n, ) ndarray
        Quadrature nodes
    w : (n, ) ndarray
        Quadrature weights
    
    """
    x, w = orthogonal.he_roots(n)
    ## normalize weights to sum to 1
    w /= sum(w)
    return (x.real, w)