# Path: examples/datautils.py
# def step(x):
# 	y = x.copy()
# 	y[y < 0.0] = 0.0
# 	y[y > 0.0] = 1.0
# 	return y + 0.05*np.random.randn(x.shape[0], 1)
# 
# def spiral(no_samples, noise=0.0):
# 	def genSpiral(N, delta):
# 		X = np.zeros((N, 2))
# 		for i in range(N):
# 			r = i * 5.0 / N
# 			t = 1.75 * i / N * 2.0 * np.pi + delta
# 			x = r * np.sin(t) + (2*np.random.rand() - 1) * noise
# 			y = r * np.cos(t) + (2*np.random.rand() - 1) * noise
# 			X[i, :] = np.array([x, y])
# 		return X
# 
# 	N = int(no_samples / 2.0)
# 	pos_x = genSpiral(N, 0)
# 	neg_x = genSpiral(N, np.pi)
# 	x = np.vstack((pos_x, neg_x))
# 	y = np.ones((2*N, 1))
# 	y[N:] = -1
# 	return x, y
# 
# Path: examples/context.py

# 
# Path: examples/context.py



import matplotlib
import numpy as np
import pdb
import matplotlib.pylab as plt
import time
    import scipy.stats as stats
from scipy import special
from .datautils import step, spiral
from .context import pep, aep, vfe
from .context import pep_tmp
    from context import utils
    from scipy.misc import logsumexp
print "importing stuff..."
matplotlib.use('Agg')


def test_gpr_gaussian_energy():
    N_train = 200
    M = 10
    D = 2
    Q = 1
    y_train = np.random.randn(N_train, Q)
    x_train = np.random.randn(N_train, D)
    model_vfe = vfe.SGPR_collapsed(x_train, y_train, M)
    params = model_vfe.init_hypers(y_train)
    # params = model_vfe.optimise(disp=False)
    logZ_vfe, _ = model_vfe.objective_function(params, N_train, alpha=0.0001)
    print 'vfe', logZ_vfe

    alphas = np.linspace(0.001, 1, 20)
    for alpha in alphas:
        model_pep = pep_tmp.SGPR_rank_one(x_train, y_train, M, lik='Gaussian')
        logZ_pep, _ = model_pep.objective_function(params, N_train, alpha=alpha)
        print alpha, logZ_pep

def test_gpr_probit_energy():
    N_train = 20
    M = 10
    D = 2
    Q = 3
    x_train = np.random.randn(N_train, D)
    y_train = 2 * np.random.randint(0, 2, size=(N_train, Q)) - 1

# Path: examples/datautils.py
# def step(x):
# 	y = x.copy()
# 	y[y < 0.0] = 0.0
# 	y[y > 0.0] = 1.0
# 	return y + 0.05*np.random.randn(x.shape[0], 1)
# 
# def spiral(no_samples, noise=0.0):
# 	def genSpiral(N, delta):
# 		X = np.zeros((N, 2))
# 		for i in range(N):
# 			r = i * 5.0 / N
# 			t = 1.75 * i / N * 2.0 * np.pi + delta
# 			x = r * np.sin(t) + (2*np.random.rand() - 1) * noise
# 			y = r * np.cos(t) + (2*np.random.rand() - 1) * noise
# 			X[i, :] = np.array([x, y])
# 		return X
# 
# 	N = int(no_samples / 2.0)
# 	pos_x = genSpiral(N, 0)
# 	neg_x = genSpiral(N, np.pi)
# 	x = np.vstack((pos_x, neg_x))
# 	y = np.ones((2*N, 1))
# 	y[N:] = -1
# 	return x, y
# 
# Path: examples/context.py

# 
# Path: examples/context.py



# Path: examples/gpr_ep_examples.py
import matplotlib
import numpy as np
import pdb
import matplotlib.pylab as plt
import time
    import scipy.stats as stats
from scipy import special
from .datautils import step, spiral
from .context import pep, aep, vfe
from .context import pep_tmp
    from context import utils
    from scipy.misc import logsumexp

print "importing stuff..."
matplotlib.use('Agg')


def test_gpr_gaussian_energy():
    N_train = 200
    M = 10
    D = 2
    Q = 1
    y_train = np.random.randn(N_train, Q)
    x_train = np.random.randn(N_train, D)
    model_vfe = vfe.SGPR_collapsed(x_train, y_train, M)
    params = model_vfe.init_hypers(y_train)
    # params = model_vfe.optimise(disp=False)
    logZ_vfe, _ = model_vfe.objective_function(params, N_train, alpha=0.0001)
    print 'vfe', logZ_vfe

    alphas = np.linspace(0.001, 1, 20)
    for alpha in alphas:
        model_pep = pep_tmp.SGPR_rank_one(x_train, y_train, M, lik='Gaussian')
        logZ_pep, _ = model_pep.objective_function(params, N_train, alpha=alpha)
        print alpha, logZ_pep

def test_gpr_probit_energy():
    N_train = 20
    M = 10
    D = 2
    Q = 3
    x_train = np.random.randn(N_train, D)
    y_train = 2 * np.random.randint(0, 2, size=(N_train, Q)) - 1

    model_vfe = vfe.SGPR(x_train, y_train, M, lik='Probit')