def __call__(self,x,cov=False): assert self._L is not None ks = _sparse_k(self._a, self._l2, x, self._x) # calculate the mean f = ks.dot(np.atleast_2d(self._alpha).T)[:,0] if not cov: return f kss = _sparse_k(self._a, self._l2, x, x) kik = np.zeros(ks.shape) for i in xrange(ks.shape[0]): kik[i,:] = self._L.solve(np.array(ks[i,:].todense())[0]) v = kss - ks.dot(kik.T) return f,v
def K(self,x,y=None): if y is None: y = x b = _sparse_k(self._a, self._l2, x, y) \ + self._s2 * sp.identity(len(x),format="csc") return b