示例#1
0
def test_cov_shape(random_process: randprocs.RandomProcess, args0: np.ndarray):
    """Test whether the covariance of the random process has the correct shape."""
    n = args0.shape[0]
    if random_process.output_dim is None:
        assert random_process.covmatrix(args0).shape == (n, n)
    else:
        assert random_process.covmatrix(args0).shape == (
            random_process.output_dim,
            random_process.output_dim,
            n,
            n,
        )
示例#2
0
def test_rp_mean_cov_evaluated_matches_rv_mean_cov(
    random_process: randprocs.RandomProcess, rng: np.random.Generator
):
    """Check whether the evaluated mean and covariance function of a random process is
    equivalent to the mean and covariance of the evaluated random process as a random
    variable."""
    x = rng.normal(size=(10, random_process.input_dim))

    np.testing.assert_allclose(
        random_process(x).mean,
        random_process.mean(x),
        err_msg=f"Mean of evaluated {repr(random_process)} does not match the "
        f"random process mean function evaluated.",
    )

    np.testing.assert_allclose(
        random_process(x).cov,
        random_process.covmatrix(x),
        err_msg=f"Covariance of evaluated {repr(random_process)} does not match the "
        f"random process mean function evaluated.",
    )