def test_acquisition_multipoint_expected_improvement():
    """
    Check if the q-EI acquisition function produces similar results as sampling
    """
    # Batch size
    k = 2

    # Set mean to one
    mu = np.ones((k))

    # Sample random 3 dimensional covarinace matrix:
    L = np.tril(np.random.sample((k, k)))
    Sigma = L @ L.T

    # Set current minimum to a random number smaller than the mean:
    current_minimum = np.random.uniform()

    # Compute acquisition:
    qei_analytic, _, _ = MultipointExpectedImprovement(None)._get_acquisition(mu, Sigma, current_minimum)
    acq_fast = MultipointExpectedImprovement(None, fast_compute=True, eps=1e-3)
    qei_analytic_fast, _, _ = acq_fast._get_acquisition(mu, Sigma, current_minimum)

    # Reference with sampling
    N = 1000000
    samples = np.random.multivariate_normal(mu, Sigma, size=N)
    qei_sampled = current_minimum - np.min(samples, axis=1)
    qei_sampled = sum(qei_sampled[qei_sampled > 0]) / float(N)

    assert np.abs(qei_sampled - qei_analytic) < TOL
    assert np.abs(qei_analytic_fast - qei_analytic) < TOL