# Path: examples/context.py



import matplotlib
import numpy as np
import pdb
import matplotlib.pylab as plt
from scipy import special
from .context import vfe, compute_kernel, compute_psi_weave
                else:
                    mu, Su = model.predict_f(
                        model.zu, alpha=alpha, marginal=False)
                    m_X_test_i = np.hstack(
                        (X_test, mf[:, :i].reshape((N_test, i))))
                    v_X_test_i = np.hstack(
                        (np.zeros_like(X_test), vf[:, :i].reshape((N_test, i))))
                    res = self.forward_prop_random_thru_post_mm(
                        model, m_X_test_i, v_X_test_i, mu, Su)
                    mf[:, i], vf[:, i] = res[0][:, 0], res[1][:, 0]

        return mf, vf

    def forward_prop_deterministic_thru_post(self, model, x, mu, Su):
        Kuu_noiseless = compute_kernel(
            2 * model.ls, 2 * model.sf, model.zu, model.zu)
        Kuu = Kuu_noiseless + np.diag(jitter * np.ones((self.M, )))
        # TODO: probably not the best way to use inv
        Kuuinv = np.linalg.inv(Kuu)
        A = np.dot(Kuuinv, mu)
        Smm = Su + np.outer(mu, mu)
        B_det = np.dot(Kuuinv, np.dot(Su, Kuuinv)) - Kuuinv
        psi0 = np.exp(2 * model.sf)
        psi1 = compute_kernel(2 * model.ls, 2 * model.sf, x, model.zu)
        mout = np.einsum('nm,md->nd', psi1, A)
        Bpsi2 = np.einsum('ab,na,nb->n', B_det, psi1, psi1)[:, np.newaxis]
        vout = psi0 + Bpsi2
        return mout, vout

    def forward_prop_random_thru_post_mm(self, model, mx, vx, mu, Su):

# Path: examples/context.py



# Path: examples/gpr_autoreg_example.py
import matplotlib
import numpy as np
import pdb
import matplotlib.pylab as plt
from scipy import special
from .context import vfe, compute_kernel, compute_psi_weave

                else:
                    mu, Su = model.predict_f(
                        model.zu, alpha=alpha, marginal=False)
                    m_X_test_i = np.hstack(
                        (X_test, mf[:, :i].reshape((N_test, i))))
                    v_X_test_i = np.hstack(
                        (np.zeros_like(X_test), vf[:, :i].reshape((N_test, i))))
                    res = self.forward_prop_random_thru_post_mm(
                        model, m_X_test_i, v_X_test_i, mu, Su)
                    mf[:, i], vf[:, i] = res[0][:, 0], res[1][:, 0]

        return mf, vf

    def forward_prop_deterministic_thru_post(self, model, x, mu, Su):
        Kuu_noiseless = compute_kernel(
            2 * model.ls, 2 * model.sf, model.zu, model.zu)
        Kuu = Kuu_noiseless + np.diag(jitter * np.ones((self.M, )))
        # TODO: probably not the best way to use inv
        Kuuinv = np.linalg.inv(Kuu)
        A = np.dot(Kuuinv, mu)
        Smm = Su + np.outer(mu, mu)
        B_det = np.dot(Kuuinv, np.dot(Su, Kuuinv)) - Kuuinv
        psi0 = np.exp(2 * model.sf)
        psi1 = compute_kernel(2 * model.ls, 2 * model.sf, x, model.zu)
        mout = np.einsum('nm,md->nd', psi1, A)
        Bpsi2 = np.einsum('ab,na,nb->n', B_det, psi1, psi1)[:, np.newaxis]
        vout = psi0 + Bpsi2
        return mout, vout

    def forward_prop_random_thru_post_mm(self, model, mx, vx, mu, Su):

        Kuu_noiseless = compute_kernel(