Exemplo n.º 1
0
def test_simple_gmm_weights():
    x = np.array([1., 1., 2., 3., 1., 3.])
    d = gmm_1d_distribution(x)

    x2 = np.array([1., 2., 3.])
    w = np.array([3., 1., 2.])
    d2 = gmm_1d_distribution(x2, weights=w)
    y2 = d2(np.array([1.1, 2.0]))

    assert d2(1.1) == y2[0],\
           "GMM distribution array & scalar results don't match"
    assert np.abs(d(1.1) - d2(1.1)) < 1e-5,\
           "GMM distribution weights not handled correctly"
    assert np.abs(d(2.0) - d2(2.0)) < 1e-5,\
           "GMM distribution weights not handled correctly"
Exemplo n.º 2
0
def test_simple_gmm_weights():
    x = np.array([1., 1., 2., 3., 1., 3.])
    d = gmm_1d_distribution(x)

    x2 = np.array([1., 2., 3.])
    w = np.array([3., 1., 2.])
    d2 = gmm_1d_distribution(x2, weights=w)
    y2 = d2(np.array([1.1, 2.0]))

    assert d2(1.1) == y2[0],\
           "GMM distribution array & scalar results don't match"
    assert np.abs(d(1.1) - d2(1.1)) < 1e-5,\
           "GMM distribution weights not handled correctly"
    assert np.abs(d(2.0) - d2(2.0)) < 1e-5,\
           "GMM distribution weights not handled correctly"
Exemplo n.º 3
0
def test_simple_gmm():
    x = np.array([1., 1., 2., 3., 1.])
    d = gmm_1d_distribution(x, min_limit=0., max_limit=4.)
    assert d(1.1) > d(3.5), "GMM distribution not behaving correctly"
    assert d(2.0) > d(3.0), "GMM distribution not behaving correctly"
    assert d(-1.0) == 0, "GMM distribution out of bounds error"
    assert d(9.0) == 0, "GMM distribution out of bounds error"

    samples = d.get_samples(n=25)
    np.testing.assert_array_less(samples, 4.)
    np.testing.assert_array_less(0., samples)
Exemplo n.º 4
0
def test_simple_gmm():
    x = np.array([1., 1., 2., 3., 1.])
    d = gmm_1d_distribution(x, min_limit=0., max_limit=4.)
    assert d(1.1) > d(3.5), "GMM distribution not behaving correctly"
    assert d(2.0) > d(3.0), "GMM distribution not behaving correctly"
    assert d(-1.0) == 0, "GMM distribution out of bounds error"
    assert d(9.0) == 0, "GMM distribution out of bounds error"

    samples = d.get_samples(n=25)
    np.testing.assert_array_less(samples, 4.)
    np.testing.assert_array_less(0., samples)