diff --git a/GPy/core/gp.py b/GPy/core/gp.py index a04ac8da..35a41cde 100644 --- a/GPy/core/gp.py +++ b/GPy/core/gp.py @@ -148,7 +148,7 @@ class GP(Model): return Ysim - def posterior_samples(self,X,size=10, full_cov=True, Y_metadata=None): + def posterior_samples(self, X, size=10, full_cov=False, Y_metadata=None): """ Samples the posterior GP at the points X. @@ -163,7 +163,7 @@ class GP(Model): :returns: Ysim: set of simulations, a Numpy array (N x samples). """ Ysim = self.posterior_samples_f(X, size, full_cov=full_cov) - Ysim = self.likelihood.noise_model.samples(Ysim, Y_metadata) + Ysim = self.likelihood.samples(Ysim, Y_metadata) return Ysim diff --git a/GPy/likelihoods/gaussian.py b/GPy/likelihoods/gaussian.py index 032136a7..aaa356b6 100644 --- a/GPy/likelihoods/gaussian.py +++ b/GPy/likelihoods/gaussian.py @@ -94,7 +94,7 @@ class Gaussian(Likelihood): return self.variance + sigma**2 def predictive_quantiles(self, mu, var, quantiles, Y_metadata): - return [stats.norm.ppf(q)*np.sqrt(var) + mu for q in quantiles] + return [stats.norm.ppf(q/100.)*np.sqrt(var) + mu for q in quantiles] def pdf_link(self, link_f, y, extra_data=None): """ diff --git a/GPy/likelihoods/likelihood.py b/GPy/likelihoods/likelihood.py index 67c406df..3eafedb1 100644 --- a/GPy/likelihoods/likelihood.py +++ b/GPy/likelihoods/likelihood.py @@ -397,7 +397,7 @@ class Likelihood(Parameterized): return [np.percentile(ss_y ,q, axis=1)[:,None] for q in quantiles] - def samples(self, gp): + def samples(self, gp, Y_metadata=None): """ Returns a set of samples of observations based on a given value of the latent variable. diff --git a/GPy/likelihoods/student_t.py b/GPy/likelihoods/student_t.py index ce86d9d6..15fd9fa0 100644 --- a/GPy/likelihoods/student_t.py +++ b/GPy/likelihoods/student_t.py @@ -263,7 +263,7 @@ class StudentT(Likelihood): def conditional_variance(self, gp): return self.deg_free/(self.deg_free - 2.) - def samples(self, gp): + def samples(self, gp, Y_metadata=None): """ Returns a set of samples of observations based on a given value of the latent variable. diff --git a/GPy/plotting/matplot_dep/models_plots.py b/GPy/plotting/matplot_dep/models_plots.py index c87eb694..7507c376 100644 --- a/GPy/plotting/matplot_dep/models_plots.py +++ b/GPy/plotting/matplot_dep/models_plots.py @@ -86,8 +86,7 @@ def plot_fit(model, plot_limits=None, which_data_rows='all', upper = m + 2*np.sqrt(v) else: m, v = model.predict(Xgrid, full_cov=False, Y_metadata=Y_metadata) - - lower, upper = model.predict_quantiles(Xgrid, Y_metadata=Y_metadata) + lower, upper = model.predict_quantiles(Xgrid, Y_metadata=Y_metadata) for d in which_data_ycols: diff --git a/GPy/testing/kernel_tests.py b/GPy/testing/kernel_tests.py index 9f366afa..d61bf6a3 100644 --- a/GPy/testing/kernel_tests.py +++ b/GPy/testing/kernel_tests.py @@ -298,6 +298,24 @@ class KernelTestsMiscellaneous(unittest.TestCase): self.assertTrue(np.allclose(self.sumkern.K(self.X, which_parts=[self.linear, self.rbf]), self.linear.K(self.X)+self.rbf.K(self.X))) self.assertTrue(np.allclose(self.sumkern.K(self.X, which_parts=self.sumkern.parts[0]), self.rbf.K(self.X))) +class KernelTestsNonContinuous(unittest.TestCase): + def setUp(self): + N = 100 + N1 = 110 + self.D = 2 + D = self.D + self.X = np.random.randn(N,D) + self.X2 = np.random.randn(N1,D) + self.X_block = np.zeros((N+N1, D+D+1)) + self.X_block[0:N, 0:D] = self.X + self.X_block[N:N+N1, D:D+D] = self.X2 + self.X_block[0:N, -1] = 1 + self.X_block[N:N+1, -1] = 2 + + def test_IndependantOutputs(self): + k = GPy.kern.RBF(self.D) + kern = GPy.kern.IndependentOutputs(self.D+self.D,k) + self.assertTrue(check_kernel_gradient_functions(kern, X=self.X, X2=self.X2, verbose=verbose)) if __name__ == "__main__": print "Running unit tests, please be (very) patient..."