def test_combine():
    x1 = B.linspace(0, 2, 10)
    x2 = B.linspace(2, 4, 10)

    m = Measure()
    p1 = GP(EQ(), measure=m)
    p2 = GP(Matern12(), measure=m)
    y1 = p1(x1).sample()
    y2 = p2(x2).sample()

    # Check the one-argument case.
    assert_equal_normals(combine(p1(x1, 1)), p1(x1, 1))
    fdd_combined, y_combined = combine((p1(x1, 1), B.squeeze(y1)))
    assert_equal_normals(fdd_combined, p1(x1, 1))
    approx(y_combined, y1)

    # Check the two-argument case.
    fdd_combined = combine(p1(x1, 1), p2(x2, 2))
    assert_equal_normals(
        fdd_combined,
        Normal(B.block_diag(p1(x1, 1).var,
                            p2(x2, 2).var)),
    )
    fdd_combined, y_combined = combine((p1(x1, 1), B.squeeze(y1)),
                                       (p2(x2, 2), y2))
    assert_equal_normals(
        fdd_combined,
        Normal(B.block_diag(p1(x1, 1).var,
                            p2(x2, 2).var)),
    )
    approx(y_combined, B.concat(y1, y2, axis=0))
示例#2
0
 def construct_model(vs):
     kernels = [
         vs.pos(1, name=f"{i}/var") *
         Matern12().stretch(vs.pos(0.1, name=f"{i}/scale"))
         for i in range(p)
     ]
     noises = vs.pos(1e-2 * B.ones(p), name="noises")
     return IGP(kernels, noises)
示例#3
0
    def construct_model(vs):
        kernels = [
            vs.pos(1, name=f"{i}/var") *
            Matern12().stretch(vs.pos(0.1, name=f"{i}/scale"))
            for i in range(m)
        ]
        noise = vs.pos(1e-2, name="noise")
        latent_noises = vs.pos(1e-2 * B.ones(m), name="latent_noises")
        h = Dense(vs.get(shape=(p, m), name="h"))

        return ILMMPP(kernels, h, noise, latent_noises)
示例#4
0
    def make_latent_process(i):
        # Long-term trend:
        variance = vs.bnd(0.9, name=f'{i}/long_term/var')
        scale = vs.bnd(2 * 30, name=f'{i}/long_term/scale')
        kernel = variance * EQ().stretch(scale)

        # Short-term trend:
        variance = vs.bnd(0.1, name=f'{i}/short_term/var')
        scale = vs.bnd(20, name=f'{i}/short_term/scale')
        kernel += variance * Matern12().stretch(scale)

        return GP(kernel, graph=g)
示例#5
0
文件: exchange.py 项目: wesselb/oilmm
    def construct_model(vs):
        kernels = [
            vs.pos(1, name=f"{i}/var") *
            Matern12().stretch(vs.pos(0.1, name=f"{i}/scale"))
            for i in range(m)
        ]
        noise = vs.pos(1e-2, name="noise")
        latent_noises = vs.pos(1e-2 * B.ones(m), name="latent_noises")
        u = Dense(vs.orth(shape=(p, m), name="u"))
        s_sqrt = Diagonal(vs.pos(shape=(m, ), name="s_sqrt"))

        return OILMM(kernels, u, s_sqrt, noise, latent_noises)
示例#6
0
文件: exchange.py 项目: wesselb/oilmm
    def construct_model_ilmm_equivalent(vs):
        kernels = [
            vs.pos(1, name=f"{i}/var") *
            Matern12().stretch(vs.pos(0.1, name=f"{i}/scale"))
            for i in range(m)
        ]
        noise = vs.pos(1e-2, name="noise")
        latent_noises = vs.pos(1e-2 * B.ones(m), name="latent_noises")
        u = vs.orth(shape=(p, m), name="u")
        s_sqrt = vs.pos(shape=(m, ), name="s_sqrt")
        h = Dense(u * s_sqrt[None, :])

        return ILMMPP(kernels, h, noise, latent_noises)