Skip to content

Commit 8ee2e61

Browse files
0.26.10 det fixed, new plots
1 parent 9a1f326 commit 8ee2e61

5 files changed

Lines changed: 222 additions & 133 deletions

File tree

notebooks/00_spotPython_tests.ipynb

Lines changed: 19 additions & 17 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotpython"
10-
version = "0.26.9"
10+
version = "0.26.10"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotpython/gp/gp_sep.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,10 @@ def _build(self) -> None:
667667
# raise RuntimeError("Covariance matrix has already been built.")
668668
self.K = covar_anisotropic(self.X, d=self.d, g=self.g)
669669
self.Ki = matrix_inversion_dispatcher(self.K, method=self.nlsep_method)
670-
self.ldetK = np.log(det(self.K))
670+
detK = det(self.K)
671+
if detK <= 1e-14:
672+
detK = 1e-14 # TODO: Check if this can be improved
673+
self.ldetK = np.log(detK)
671674
self.calc_ytKiy()
672675
# TODO: Check if this is necessary
673676
# if self.dK:

src/spotpython/gp/likelihood.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ def nlsep(par, X, Y, nlsep_method="inv") -> float:
99
Calculate the negative log-likelihood for a separable power exponential correlation function.
1010
1111
Args:
12-
par (np.ndarray): Array of parameters, where the first ncol(X) elements are the range parameters
13-
and the last element is the nugget parameter.
14-
X (np.ndarray): Input matrix of shape (n, col).
15-
Y (np.ndarray): Response vector of shape (n,).
12+
par (np.ndarray):
13+
Array of parameters, where the first ncol(X) elements are the range parameters and the last element is the nugget parameter.
14+
X (np.ndarray):
15+
Input matrix of shape (n, col).
16+
Y (np.ndarray):
17+
Response vector of shape (n,).
1618
1719
Returns:
1820
float: Negative log-likelihood.
@@ -32,7 +34,10 @@ def nlsep(par, X, Y, nlsep_method="inv") -> float:
3234
n = len(Y)
3335
K = covar_anisotropic(X, d=theta, g=g)
3436
Ki = matrix_inversion_dispatcher(K, method=nlsep_method)
35-
ldetK = np.log(det(K))
37+
detK = det(K)
38+
if detK <= 1e-14:
39+
detK = 1e-14 # TODO: Check if this can be improved
40+
ldetK = np.log(detK)
3641
ll = -(n / 2) * np.log(Y.T @ Ki @ Y) - (1 / 2) * ldetK
3742
return -ll
3843

0 commit comments

Comments
 (0)