pygeoinf 1.2.6__py3-none-any.whl → 1.2.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygeoinf/__init__.py +6 -1
- pygeoinf/gaussian_measure.py +25 -36
- pygeoinf/linear_operators.py +957 -133
- pygeoinf/linear_solvers.py +39 -7
- pygeoinf/random_matrix.py +114 -0
- {pygeoinf-1.2.6.dist-info → pygeoinf-1.2.8.dist-info}/METADATA +8 -15
- {pygeoinf-1.2.6.dist-info → pygeoinf-1.2.8.dist-info}/RECORD +9 -9
- {pygeoinf-1.2.6.dist-info → pygeoinf-1.2.8.dist-info}/LICENSE +0 -0
- {pygeoinf-1.2.6.dist-info → pygeoinf-1.2.8.dist-info}/WHEEL +0 -0
pygeoinf/__init__.py
CHANGED
|
@@ -9,6 +9,7 @@ from .random_matrix import (
|
|
|
9
9
|
random_svd,
|
|
10
10
|
random_eig,
|
|
11
11
|
random_cholesky,
|
|
12
|
+
random_diagonal,
|
|
12
13
|
)
|
|
13
14
|
|
|
14
15
|
from .hilbert_space import (
|
|
@@ -34,7 +35,11 @@ from .nonlinear_operators import NonLinearOperator
|
|
|
34
35
|
|
|
35
36
|
from .linear_operators import (
|
|
36
37
|
LinearOperator,
|
|
37
|
-
|
|
38
|
+
MatrixLinearOperator,
|
|
39
|
+
DenseMatrixLinearOperator,
|
|
40
|
+
SparseMatrixLinearOperator,
|
|
41
|
+
DiagonalSparseMatrixLinearOperator,
|
|
42
|
+
NormalSumOperator,
|
|
38
43
|
)
|
|
39
44
|
|
|
40
45
|
|
pygeoinf/gaussian_measure.py
CHANGED
|
@@ -28,11 +28,11 @@ from scipy.sparse import diags
|
|
|
28
28
|
from scipy.stats import multivariate_normal
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
from .hilbert_space import EuclideanSpace, HilbertModule
|
|
31
|
+
from .hilbert_space import EuclideanSpace, HilbertModule, Vector
|
|
32
32
|
|
|
33
33
|
from .linear_operators import (
|
|
34
34
|
LinearOperator,
|
|
35
|
-
|
|
35
|
+
DiagonalSparseMatrixLinearOperator,
|
|
36
36
|
)
|
|
37
37
|
|
|
38
38
|
from .direct_sum import (
|
|
@@ -40,17 +40,6 @@ from .direct_sum import (
|
|
|
40
40
|
)
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
# This block only runs for type checkers, not at runtime, to prevent
|
|
44
|
-
# circular import errors while still allowing type hints.
|
|
45
|
-
if TYPE_CHECKING:
|
|
46
|
-
from .hilbert_space import HilbertSpace, EuclideanSpace
|
|
47
|
-
from .operators import LinearOperator, DiagonalLinearOperator
|
|
48
|
-
from .direct_sum import BlockDiagonalLinearOperator
|
|
49
|
-
|
|
50
|
-
# Define a generic type for vectors in a Hilbert space
|
|
51
|
-
Vector = TypeVar("Vector")
|
|
52
|
-
|
|
53
|
-
|
|
54
43
|
class GaussianMeasure:
|
|
55
44
|
"""
|
|
56
45
|
Represents a Gaussian measure on a Hilbert space.
|
|
@@ -76,29 +65,29 @@ class GaussianMeasure:
|
|
|
76
65
|
inverse_covariance_factor: LinearOperator = None,
|
|
77
66
|
) -> None:
|
|
78
67
|
"""
|
|
79
|
-
|
|
68
|
+
Initializes the GaussianMeasure.
|
|
80
69
|
|
|
81
70
|
The measure can be defined in several ways, primarily by providing
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
71
|
+
either a covariance operator or a covariance factor.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
covariance (LinearOperator, optional): A self-adjoint and positive
|
|
75
|
+
semi-definite linear operator on the domain.
|
|
76
|
+
covariance_factor (LinearOperator, optional): A linear operator L
|
|
77
|
+
such that the covariance C = L @ L*.
|
|
78
|
+
expectation (vector, optional): The expectation (mean) of the
|
|
79
|
+
measure. Defaults to the zero vector of the space.
|
|
80
|
+
sample (callable, optional): A function that returns a random
|
|
81
|
+
sample from the measure. If a `covariance_factor` is given,
|
|
82
|
+
a default sampler is created.
|
|
83
|
+
inverse_covariance (LinearOperator, optional): The inverse of the
|
|
84
|
+
covariance operator (the precision operator).
|
|
85
|
+
inverse_covariance_factor (LinearOperator, optional): A factor Li
|
|
86
|
+
of the inverse covariance, such that C_inv = Li.T @ Li.
|
|
87
|
+
|
|
88
|
+
Raises:
|
|
89
|
+
ValueError: If neither `covariance` nor `covariance_factor`
|
|
90
|
+
is provided.
|
|
102
91
|
"""
|
|
103
92
|
if covariance is None and covariance_factor is None:
|
|
104
93
|
raise ValueError(
|
|
@@ -186,8 +175,8 @@ class GaussianMeasure:
|
|
|
186
175
|
"Standard deviation vector does not have the correct length"
|
|
187
176
|
)
|
|
188
177
|
euclidean = EuclideanSpace(domain.dim)
|
|
189
|
-
covariance_factor =
|
|
190
|
-
euclidean, domain, standard_deviations
|
|
178
|
+
covariance_factor = DiagonalSparseMatrixLinearOperator.from_diagonal_values(
|
|
179
|
+
euclidean, domain, standard_deviations
|
|
191
180
|
)
|
|
192
181
|
return GaussianMeasure(
|
|
193
182
|
covariance_factor=covariance_factor,
|