示例#1
0
def test_linear_transform_2d():
    p0 = MultivariateNormal(mu=np.array([0.0, 1.0]), sigma=np.eye(2))
    pt = LinearTransform(p0, A=np.array([[1.0, 0], [0.0, 0.5]]))

    X0 = p0.rvs(10, random_state=0)
    Xt = pt.rvs(10, random_state=0)

    assert X0.shape == Xt.shape
    assert_array_equal(p0.pdf(X0), pt.pdf(Xt))
    assert_array_equal(p0.nll(X0), pt.nll(Xt))
示例#2
0
def test_linear_transform_2d():
    p0 = MultivariateNormal(mu=np.array([0., 1.]), sigma=np.eye(2))
    pt = LinearTransform(p0, A=np.array([[1.0, 0], [0., 0.5]]))

    X0 = p0.rvs(10, random_state=0)
    Xt = pt.rvs(10, random_state=0)

    assert X0.shape == Xt.shape
    assert_array_equal(p0.pdf(X0), pt.pdf(Xt))
    assert_array_equal(p0.nll(X0), pt.nll(Xt))
示例#3
0
def test_linear_transform_1d():
    p0 = Normal()
    pt = LinearTransform(p0, A=np.array([[0.5]]))

    X0 = p0.rvs(10, random_state=0)
    Xt = pt.rvs(10, random_state=0)

    assert X0.shape == Xt.shape
    assert_array_equal(X0 * 0.5, Xt)
    assert_array_equal(p0.pdf(X0), pt.pdf(Xt))
    assert_array_equal(p0.nll(X0), pt.nll(Xt))
示例#4
0
def test_linear_transform_1d():
    p0 = Normal()
    pt = LinearTransform(p0, A=np.array([[0.5]]))

    X0 = p0.rvs(10, random_state=0)
    Xt = pt.rvs(10, random_state=0)

    assert X0.shape == Xt.shape
    assert_array_equal(X0 * 0.5, Xt)
    assert_array_equal(p0.pdf(X0), pt.pdf(Xt))
    assert_array_equal(p0.nll(X0), pt.nll(Xt))