Skip to content

Commit ab4b537

Browse files
danhphanmichaelosthege
authored andcommitted
update the default value of jitter to JITTER_DEFAULT
1 parent 4bd1a2d commit ab4b537

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

pymc/gp/gp.py

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def prior(self, name, X, reparameterize=True, jitter=JITTER_DEFAULT, **kwargs):
160160
variable by the Cholesky factor of the covariance matrix.
161161
jitter: scalar
162162
A small correction added to the diagonal of positive semi-definite
163-
covariance matrices to ensure numerical stability. Default value is 1e-6.
163+
covariance matrices to ensure numerical stability.
164164
**kwargs
165165
Extra keyword arguments that are passed to distribution constructor.
166166
"""
@@ -196,7 +196,7 @@ def _build_conditional(self, Xnew, X, f, cov_total, mean_total, jitter):
196196
cov = Kss - at.dot(at.transpose(A), A)
197197
return mu, cov
198198

199-
def conditional(self, name, Xnew, given=None, jitter=0.0, **kwargs):
199+
def conditional(self, name, Xnew, given=None, jitter=JITTER_DEFAULT, **kwargs):
200200
R"""
201201
Returns the conditional distribution evaluated over new input
202202
locations `Xnew`.
@@ -223,8 +223,7 @@ def conditional(self, name, Xnew, given=None, jitter=0.0, **kwargs):
223223
models in PyMC for more information.
224224
jitter: scalar
225225
A small correction added to the diagonal of positive semi-definite
226-
covariance matrices to ensure numerical stability. For conditionals
227-
the default value is 0.0.
226+
covariance matrices to ensure numerical stability.
228227
**kwargs
229228
Extra keyword arguments that are passed to `MvNormal` distribution
230229
constructor.
@@ -324,7 +323,7 @@ def _build_conditional(self, Xnew, X, f, jitter):
324323
covT = (self.nu + beta - 2) / (nu2 - 2) * cov
325324
return nu2, mu, covT
326325

327-
def conditional(self, name, Xnew, jitter=0.0, **kwargs):
326+
def conditional(self, name, Xnew, jitter=JITTER_DEFAULT, **kwargs):
328327
R"""
329328
Returns the conditional distribution evaluated over new input
330329
locations `Xnew`.
@@ -341,8 +340,7 @@ def conditional(self, name, Xnew, jitter=0.0, **kwargs):
341340
Function input values.
342341
jitter: scalar
343342
A small correction added to the diagonal of positive semi-definite
344-
covariance matrices to ensure numerical stability. For conditionals
345-
the default value is 0.0.
343+
covariance matrices to ensure numerical stability.
346344
**kwargs
347345
Extra keyword arguments that are passed to `MvNormal` distribution
348346
constructor.
@@ -407,7 +405,9 @@ def _build_marginal_likelihood(self, X, noise, jitter):
407405
cov = Kxx + Knx
408406
return mu, stabilize(cov, jitter)
409407

410-
def marginal_likelihood(self, name, X, y, noise, jitter=0.0, is_observed=True, **kwargs):
408+
def marginal_likelihood(
409+
self, name, X, y, noise, jitter=JITTER_DEFAULT, is_observed=True, **kwargs
410+
):
411411
R"""
412412
Returns the marginal likelihood distribution, given the input
413413
locations `X` and the data `y`.
@@ -433,7 +433,7 @@ def marginal_likelihood(self, name, X, y, noise, jitter=0.0, is_observed=True, *
433433
non-white noise.
434434
jitter: scalar
435435
A small correction added to the diagonal of positive semi-definite
436-
covariance matrices to ensure numerical stability. Default value is 0.0.
436+
covariance matrices to ensure numerical stability.
437437
**kwargs
438438
Extra keyword arguments that are passed to `MvNormal` distribution
439439
constructor.
@@ -497,7 +497,9 @@ def _build_conditional(
497497
cov += noise(Xnew)
498498
return mu, cov if pred_noise else stabilize(cov, jitter)
499499

500-
def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kwargs):
500+
def conditional(
501+
self, name, Xnew, pred_noise=False, given=None, jitter=JITTER_DEFAULT, **kwargs
502+
):
501503
R"""
502504
Returns the conditional distribution evaluated over new input
503505
locations `Xnew`.
@@ -527,8 +529,7 @@ def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kw
527529
models in PyMC for more information.
528530
jitter: scalar
529531
A small correction added to the diagonal of positive semi-definite
530-
covariance matrices to ensure numerical stability. For conditionals
531-
the default value is 0.0.
532+
covariance matrices to ensure numerical stability.
532533
**kwargs
533534
Extra keyword arguments that are passed to `MvNormal` distribution
534535
constructor.
@@ -539,7 +540,14 @@ def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kw
539540
return pm.MvNormal(name, mu=mu, cov=cov, **kwargs)
540541

541542
def predict(
542-
self, Xnew, point=None, diag=False, pred_noise=False, given=None, jitter=0.0, model=None
543+
self,
544+
Xnew,
545+
point=None,
546+
diag=False,
547+
pred_noise=False,
548+
given=None,
549+
jitter=JITTER_DEFAULT,
550+
model=None,
543551
):
544552
R"""
545553
Return the mean vector and covariance matrix of the conditional
@@ -563,15 +571,14 @@ def predict(
563571
Same as `conditional` method.
564572
jitter: scalar
565573
A small correction added to the diagonal of positive semi-definite
566-
covariance matrices to ensure numerical stability. For conditionals
567-
the default value is 0.0.
574+
covariance matrices to ensure numerical stability.
568575
"""
569576
if given is None:
570577
given = {}
571578
mu, cov = self._predict_at(Xnew, diag, pred_noise, given, jitter)
572579
return replace_with_values([mu, cov], replacements=point, model=model)
573580

574-
def _predict_at(self, Xnew, diag=False, pred_noise=False, given=None, jitter=0.0):
581+
def _predict_at(self, Xnew, diag=False, pred_noise=False, given=None, jitter=JITTER_DEFAULT):
575582
R"""
576583
Return the mean vector and covariance matrix of the conditional
577584
distribution as symbolic variables.
@@ -712,7 +719,7 @@ def _build_marginal_likelihood_logp(self, y, X, Xu, sigma, jitter):
712719
return -1.0 * (constant + logdet + quadratic + trace)
713720

714721
def marginal_likelihood(
715-
self, name, X, Xu, y, noise=None, is_observed=True, jitter=0.0, **kwargs
722+
self, name, X, Xu, y, noise=None, is_observed=True, jitter=JITTER_DEFAULT, **kwargs
716723
):
717724
R"""
718725
Returns the approximate marginal likelihood distribution, given the input
@@ -738,7 +745,7 @@ def marginal_likelihood(
738745
Default is `True`.
739746
jitter: scalar
740747
A small correction added to the diagonal of positive semi-definite
741-
covariance matrices to ensure numerical stability. Default value is 0.0.
748+
covariance matrices to ensure numerical stability.
742749
**kwargs
743750
Extra keyword arguments that are passed to `MvNormal` distribution
744751
constructor.
@@ -836,7 +843,9 @@ def _get_given_vals(self, given):
836843
X, Xu, y, sigma = self.X, self.Xu, self.y, self.sigma
837844
return X, Xu, y, sigma, cov_total, mean_total
838845

839-
def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kwargs):
846+
def conditional(
847+
self, name, Xnew, pred_noise=False, given=None, jitter=JITTER_DEFAULT, **kwargs
848+
):
840849
R"""
841850
Returns the approximate conditional distribution of the GP evaluated over
842851
new input locations `Xnew`.
@@ -857,8 +866,7 @@ def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kw
857866
models in PyMC for more information.
858867
jitter: scalar
859868
A small correction added to the diagonal of positive semi-definite
860-
covariance matrices to ensure numerical stability. For conditionals
861-
the default value is 0.0.
869+
covariance matrices to ensure numerical stability.
862870
**kwargs
863871
Extra keyword arguments that are passed to `MvNormal` distribution
864872
constructor.
@@ -968,7 +976,7 @@ def prior(self, name, Xs, jitter=JITTER_DEFAULT, **kwargs):
968976
`cartesian(*Xs)`.
969977
jitter: scalar
970978
A small correction added to the diagonal of positive semi-definite
971-
covariance matrices to ensure numerical stability. Default value is 1e-6.
979+
covariance matrices to ensure numerical stability.
972980
**kwargs
973981
Extra keyword arguments that are passed to the `KroneckerNormal`
974982
distribution constructor.
@@ -998,7 +1006,7 @@ def _build_conditional(self, Xnew, jitter):
9981006
cov = stabilize(Kss - at.dot(at.transpose(A), A), jitter)
9991007
return mu, cov
10001008

1001-
def conditional(self, name, Xnew, jitter=0.0, **kwargs):
1009+
def conditional(self, name, Xnew, jitter=JITTER_DEFAULT, **kwargs):
10021010
"""
10031011
Returns the conditional distribution evaluated over new input
10041012
locations `Xnew`.
@@ -1027,8 +1035,7 @@ def conditional(self, name, Xnew, jitter=0.0, **kwargs):
10271035
vector with shape `(n, 1)`.
10281036
jitter: scalar
10291037
A small correction added to the diagonal of positive semi-definite
1030-
covariance matrices to ensure numerical stability. For conditionals
1031-
the default value is 0.0.
1038+
covariance matrices to ensure numerical stability.
10321039
**kwargs
10331040
Extra keyword arguments that are passed to `MvNormal` distribution
10341041
constructor.

0 commit comments

Comments
 (0)