more fixing of the predictive variance (correct for full_cov now)

This commit is contained in:
James Hensman 2013-03-13 10:37:46 +00:00
parent e9508b40f9
commit 128b2b90ef
3 changed files with 19 additions and 7 deletions

View file

@ -33,7 +33,9 @@ class EP(likelihood):
self.Z = 0
self.YYT = None
def predictive_values(self,mu,var):
def predictive_values(self,mu,var,full_cov):
if full_cov:
raise NotImplementedError, "Cannot make correlated predictions with an EP likelihood"
return self.likelihood_function.predictive_values(mu,var)
def _get_params(self):

View file

@ -43,14 +43,24 @@ class Gaussian(likelihood):
self.covariance_matrix = np.eye(self.N)*self._variance
self.precision = 1./self._variance
def predictive_values(self,mu,var):
def predictive_values(self,mu,var, full_cov):
"""
Un-normalize the prediction and add the likelihood variance, then return the 5%, 95% interval
"""
mean = mu*self._std + self._mean
true_var = (var + self._variance)*self._std**2
_5pc = mean + - 2.*np.sqrt(true_var)
_95pc = mean + 2.*np.sqrt(true_var)
if full_cov:
if self.D >1:
raise NotImplementedError, "TODO"
#Note. for D>1, we need to re-normalise all the outputs independently.
# This will mess up computations of diag(true_var), below.
#note that the upper, lower quantiles should be the same shape as mean
true_var = (var + np.eye(var.shape[0])*self._variance)*self._std**2
_5pc = mean + - 2.*np.sqrt(np.diag(true_var))
_95pc = mean + 2.*np.sqrt(np.diag(true_var))
else:
true_var = (var + self._variance)*self._std**2
_5pc = mean + - 2.*np.sqrt(true_var)
_95pc = mean + 2.*np.sqrt(true_var)
return mean, true_var, _5pc, _95pc
def fit_full(self):