# Path: examples/context.py



import numpy as np
import pdb
import matplotlib.pylab as plt
    import GPy
from .context import aep, ep
from scipy import special
    from operator import xor
    from scipy import special
    angles = np.arccos(cos_val)
    sin_val = np.sin(angles)
    Y = np.hstack((sin_val, cos_val))
    Y += 0.05 * np.random.randn(Y.shape[0], Y.shape[1])

    # inference
    print "inference ..."
    M = 10
    D = 1
    alpha = 0.2
    lvm_aep = aep.SGPLVM(Y, D, M, lik='Gaussian')
    lvm_aep.optimise(method='L-BFGS-B', alpha=alpha, maxiter=2000)

    plt.figure()
    plt.plot(Y[:, 0], Y[:, 1], 'sb')

    mx, vx = lvm_aep.get_posterior_x()
    for i in range(mx.shape[0]):
        mxi = mx[i, :]
        vxi = vx[i, :]
        mxi1 = mxi + np.sqrt(vxi)
        mxi2 = mxi - np.sqrt(vxi)
        mxis = np.vstack([mxi.reshape((1, D)),
                          mxi1.reshape((1, D)),
                          mxi2.reshape((1, D))])
        myis, vyis = lvm_aep.predict_f(mxis)

        plt.errorbar(myis[:, 0], myis[:, 1],
                     xerr=np.sqrt(vyis[:, 0]), yerr=np.sqrt(vyis[:, 1]), fmt='.k')


# Path: examples/context.py



# Path: examples/gplvm_ep_examples.py
import numpy as np
import pdb
import matplotlib.pylab as plt
    import GPy
from .context import aep, ep
from scipy import special
    from operator import xor
    from scipy import special

    angles = np.arccos(cos_val)
    sin_val = np.sin(angles)
    Y = np.hstack((sin_val, cos_val))
    Y += 0.05 * np.random.randn(Y.shape[0], Y.shape[1])

    # inference
    print "inference ..."
    M = 10
    D = 1
    alpha = 0.2
    lvm_aep = aep.SGPLVM(Y, D, M, lik='Gaussian')
    lvm_aep.optimise(method='L-BFGS-B', alpha=alpha, maxiter=2000)

    plt.figure()
    plt.plot(Y[:, 0], Y[:, 1], 'sb')

    mx, vx = lvm_aep.get_posterior_x()
    for i in range(mx.shape[0]):
        mxi = mx[i, :]
        vxi = vx[i, :]
        mxi1 = mxi + np.sqrt(vxi)
        mxi2 = mxi - np.sqrt(vxi)
        mxis = np.vstack([mxi.reshape((1, D)),
                          mxi1.reshape((1, D)),
                          mxi2.reshape((1, D))])
        myis, vyis = lvm_aep.predict_f(mxis)

        plt.errorbar(myis[:, 0], myis[:, 1],
                     xerr=np.sqrt(vyis[:, 0]), yerr=np.sqrt(vyis[:, 1]), fmt='.k')


    lvm = ep.SGPLVM(Y, D, M, lik='Gaussian')