How to use the celerite.CholeskySolver function in celerite

To help you get started, we’ve selected a few celerite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dfm / celerite / tests / test_celerite.py View on Github external
def test_pickle(with_general, seed=42):
    solver = celerite.CholeskySolver()
    np.random.seed(seed)
    t = np.sort(np.random.rand(500))
    diag = np.random.uniform(0.1, 0.5, len(t))
    y = np.sin(t)

    if with_general:
        U = np.vander(t - np.mean(t), 4).T
        V = U * np.random.rand(4)[:, None]
        A = np.sum(U * V, axis=0) + 1e-8
    else:
        A = np.empty(0)
        U = np.empty((0, 0))
        V = np.empty((0, 0))

    alpha_real = np.array([1.3, 1.5])
    beta_real = np.array([0.5, 0.2])
github dfm / celerite / tests / test_celerite.py View on Github external
def test_dot(with_general, seed=42):
    solver = celerite.CholeskySolver()
    np.random.seed(seed)
    t = np.sort(np.random.rand(500))
    b = np.random.randn(len(t), 5)

    alpha_real = np.array([1.3, 0.2])
    beta_real = np.array([0.5, 0.8])
    alpha_complex_real = np.array([0.1])
    alpha_complex_imag = np.array([0.0])
    beta_complex_real = np.array([1.5])
    beta_complex_imag = np.array([0.1])

    K = get_kernel_value(
        alpha_real, beta_real, alpha_complex_real, alpha_complex_imag,
        beta_complex_real, beta_complex_imag, t[:, None] - t[None, :]
    )
github dfm / celerite / tests / test_celerite.py View on Github external
def test_carma(seed=42):
    solver = celerite.CholeskySolver()
    np.random.seed(seed)
    t = np.sort(np.random.uniform(0, 5, 100))
    yerr = 0.1 + np.zeros_like(t)
    y = np.sin(t) + yerr * np.random.randn(len(t))

    carma_solver = CARMASolver(-0.5, np.array([0.1, 0.05, 0.01]),
                               np.array([0.2, 0.1]))
    carma_ll = carma_solver.log_likelihood(t, y, yerr)
    params = carma_solver.get_celerite_coeffs()

    solver.compute(
        0.0, params[0], params[1], params[2], params[3], params[4], params[5],
        np.empty(0), np.empty((0, 0)), np.empty((0, 0)),
        t, yerr**2
    )
    celerite_ll = -0.5*(
github dfm / celerite / tests / test_celerite.py View on Github external
def _test_solve(alpha_real, beta_real, alpha_complex_real, alpha_complex_imag,
                beta_complex_real, beta_complex_imag, seed=42,
                with_general=False):
    solver = celerite.CholeskySolver()
    np.random.seed(seed)
    t = np.sort(np.random.rand(500))
    diag = np.random.uniform(0.1, 0.5, len(t))
    b = np.random.randn(len(t))

    with pytest.raises(RuntimeError):
        solver.log_determinant()
    with pytest.raises(RuntimeError):
        solver.dot_solve(b)

    if with_general:
        U = np.vander(t - np.mean(t), 4).T
        V = U * np.random.rand(4)[:, None]
        A = np.sum(U * V, axis=0) + 1e-8
    else:
        A = np.empty(0)
github dfm / celerite / tests / test_celerite.py View on Github external
def _test_log_determinant(alpha_real, beta_real, alpha_complex_real,
                          alpha_complex_imag, beta_complex_real,
                          beta_complex_imag, seed=42):
    solver = celerite.CholeskySolver()
    np.random.seed(seed)
    t = np.sort(np.random.rand(5))
    diag = np.random.uniform(0.1, 0.5, len(t))

    solver.compute(
        0.0, alpha_real, beta_real, alpha_complex_real, alpha_complex_imag,
        beta_complex_real, beta_complex_imag,
        np.empty(0), np.empty((0, 0)), np.empty((0, 0)),
        t, diag
    )
    K = get_kernel_value(
        alpha_real, beta_real, alpha_complex_real, alpha_complex_imag,
        beta_complex_real, beta_complex_imag, t[:, None] - t[None, :]
    )
    K[np.diag_indices_from(K)] += diag
    assert np.allclose(solver.log_determinant(), np.linalg.slogdet(K)[1])
github dfm / celerite / tests / test_celerite.py View on Github external
def test_dot_L(with_general, seed=42):
    solver = celerite.CholeskySolver()
    np.random.seed(seed)
    t = np.sort(np.random.rand(5))
    b = np.random.randn(len(t), 5)
    yerr = np.random.uniform(0.1, 0.5, len(t))

    alpha_real = np.array([1.3, 0.2])
    beta_real = np.array([0.5, 0.8])
    alpha_complex_real = np.array([0.1])
    alpha_complex_imag = np.array([0.0])
    beta_complex_real = np.array([1.5])
    beta_complex_imag = np.array([0.1])

    K = get_kernel_value(
        alpha_real, beta_real, alpha_complex_real, alpha_complex_imag,
        beta_complex_real, beta_complex_imag, t[:, None] - t[None, :]
    )