예제 #1
0
def test_mean_shape(random_process: randprocs.RandomProcess,
                    args0: np.ndarray):
    """Test whether the mean of the random process has the correct shape."""
    if random_process.output_dim == 1:
        assert random_process.mean(args0).ndim == 1
    else:
        assert random_process.mean(args0).shape[1] == random_process.output_dim
예제 #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.",
    )
예제 #3
0
def test_mean_shape(random_process: randprocs.RandomProcess,
                    args0: np.ndarray):
    """Test whether the mean of the random process has the correct shape."""
    expected_shape = args0.shape[:-1] + random_process.output_shape
    assert random_process.mean(args0).shape == expected_shape