mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-05 14:55:15 +02:00
more work on the posterior class
This commit is contained in:
parent
83a49f132a
commit
ee68377f5e
1 changed files with 9 additions and 3 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from ...util.linalg import pdinv, dpotrs
|
||||||
|
|
||||||
class Posterior(object):
|
class Posterior(object):
|
||||||
"""
|
"""
|
||||||
|
|
@ -42,6 +43,8 @@ class Posterior(object):
|
||||||
cov
|
cov
|
||||||
K_chol (for lazy computation)
|
K_chol (for lazy computation)
|
||||||
|
|
||||||
|
Of course, you can supply more than that, but this class will lazily compute all other quantites on demand.
|
||||||
|
|
||||||
From the supplied quantities, all of the others will be computed on demand (lazy computation)
|
From the supplied quantities, all of the others will be computed on demand (lazy computation)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
@ -84,20 +87,23 @@ class Posterior(object):
|
||||||
@property
|
@property
|
||||||
def precision(self):
|
def precision(self):
|
||||||
if self._precision is None:
|
if self._precision is None:
|
||||||
self._precision = np.linalg.inv(self.covariance)
|
self._precision, _, _, _ = pdinv(self.covariance)
|
||||||
return self._precision
|
return self._precision
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def woodbury_chol(self):
|
def woodbury_chol(self):
|
||||||
if self._woodbury_chol is None:
|
if self._woodbury_chol is None:
|
||||||
???
|
B = self._K - self._covariance
|
||||||
|
tmp, _ = dpotrs(self._K_chol, B)
|
||||||
|
Wi, _ = dpotrs(self._K_chol, tmp.T)
|
||||||
|
_, _, self._woodbury_chol, _ = pdinv(Wi)
|
||||||
else:
|
else:
|
||||||
return self._woodbury_chol
|
return self._woodbury_chol
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def woodbury_vector(self):
|
def woodbury_vector(self):
|
||||||
if self._woodbury_vector is None:
|
if self._woodbury_vector is None:
|
||||||
???
|
self._woodbury_vector, _ = dpotrs(self._K_chol, self.mean)
|
||||||
else:
|
else:
|
||||||
return self._woodbury_vector
|
return self._woodbury_vector
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue