pygeoinf 1.0.9__py3-none-any.whl → 1.1.0__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 +5 -1
- pygeoinf/direct_sum.py +101 -75
- pygeoinf/forward_problem.py +33 -32
- pygeoinf/gaussian_measure.py +97 -71
- pygeoinf/hilbert_space.py +517 -241
- pygeoinf/inversion.py +16 -4
- pygeoinf/linear_bayesian.py +57 -36
- pygeoinf/linear_forms.py +169 -0
- pygeoinf/linear_optimisation.py +34 -23
- pygeoinf/linear_solvers.py +74 -247
- pygeoinf/operators.py +175 -36
- pygeoinf/random_matrix.py +36 -32
- pygeoinf/symmetric_space/circle.py +347 -202
- pygeoinf/symmetric_space/sphere.py +335 -448
- pygeoinf/symmetric_space/symmetric_space.py +330 -142
- {pygeoinf-1.0.9.dist-info → pygeoinf-1.1.0.dist-info}/METADATA +1 -2
- pygeoinf-1.1.0.dist-info/RECORD +20 -0
- pygeoinf/forms.py +0 -128
- pygeoinf/symmetric_space/line.py +0 -384
- pygeoinf-1.0.9.dist-info/RECORD +0 -21
- {pygeoinf-1.0.9.dist-info → pygeoinf-1.1.0.dist-info}/LICENSE +0 -0
- {pygeoinf-1.0.9.dist-info → pygeoinf-1.1.0.dist-info}/WHEEL +0 -0
|
@@ -1,99 +1,71 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Provides an abstract framework for function spaces on symmetric manifolds.
|
|
3
|
+
|
|
4
|
+
This module offers a powerful abstract framework for defining Hilbert spaces of
|
|
5
|
+
functions on symmetric spaces (like spheres or tori). The core design
|
|
6
|
+
leverages the spectral properties of the Laplace-Beltrami operator (Δ), which
|
|
7
|
+
is fundamental to the geometry of these spaces.
|
|
8
|
+
|
|
9
|
+
By inheriting from these base classes and implementing a few key abstract
|
|
10
|
+
methods (like the Laplacian eigenvalues), a concrete class can automatically
|
|
11
|
+
gain a rich set of tools for defining invariant operators and probability
|
|
12
|
+
measures. This is a cornerstone of fields like spatial statistics and
|
|
13
|
+
geometric machine learning.
|
|
14
|
+
|
|
15
|
+
Key Classes
|
|
16
|
+
-----------
|
|
17
|
+
AbstractInvariantLebesgueSpace
|
|
18
|
+
An abstract base class for L²-type spaces. It provides methods to construct
|
|
19
|
+
operators that are functions of the Laplacian (`f(Δ)`) and to build
|
|
20
|
+
statistically isotropic (rotationally-invariant) Gaussian measures.
|
|
21
|
+
|
|
22
|
+
AbstractInvariantSobolevSpace
|
|
23
|
+
An abstract base class for Sobolev spaces (Hˢ). It extends the Lebesgue
|
|
24
|
+
functionality with features that require higher smoothness, most notably
|
|
25
|
+
point evaluation via Dirac delta functionals, which is essential for
|
|
26
|
+
|
|
27
|
+
connecting the abstract function space to discrete data points.
|
|
3
28
|
"""
|
|
4
29
|
|
|
5
30
|
from __future__ import annotations
|
|
6
31
|
from abc import ABC, abstractmethod
|
|
7
|
-
from typing import Callable, Any, List
|
|
32
|
+
from typing import Callable, Any, List
|
|
8
33
|
import numpy as np
|
|
34
|
+
from scipy.sparse import diags
|
|
9
35
|
|
|
10
|
-
from pygeoinf.hilbert_space import
|
|
36
|
+
from pygeoinf.hilbert_space import EuclideanSpace, HilbertSpace
|
|
11
37
|
from pygeoinf.operators import LinearOperator
|
|
12
|
-
from pygeoinf.
|
|
38
|
+
from pygeoinf.linear_forms import LinearForm
|
|
13
39
|
from pygeoinf.gaussian_measure import GaussianMeasure
|
|
14
40
|
|
|
15
41
|
|
|
16
|
-
class
|
|
42
|
+
class AbstractInvariantLebesgueSpace(ABC):
|
|
17
43
|
"""
|
|
18
|
-
An abstract base class for
|
|
44
|
+
An abstract base class for L² function spaces on symmetric manifolds.
|
|
19
45
|
|
|
20
|
-
This
|
|
21
|
-
|
|
22
|
-
|
|
46
|
+
This ABC defines the interface for spaces of square-integrable functions.
|
|
47
|
+
It provides a powerful suite of methods for creating invariant
|
|
48
|
+
operators and Gaussian measures by leveraging the spectrum of the
|
|
49
|
+
Laplace-Beltrami operator.
|
|
23
50
|
"""
|
|
24
51
|
|
|
25
|
-
def __init__(
|
|
26
|
-
self,
|
|
27
|
-
order: float,
|
|
28
|
-
scale: float,
|
|
29
|
-
dim: int,
|
|
30
|
-
to_components: Callable[[Any], np.ndarray],
|
|
31
|
-
from_components: Callable[[np.ndarray], Any],
|
|
32
|
-
inner_product: Callable[[Any, Any], float],
|
|
33
|
-
to_dual: Callable[[Any], "LinearForm"],
|
|
34
|
-
from_dual: Callable[["LinearForm"], Any],
|
|
35
|
-
/,
|
|
36
|
-
*,
|
|
37
|
-
add: Optional[Callable[[T_vec, T_vec], T_vec]] = None,
|
|
38
|
-
subtract: Optional[Callable[[T_vec, T_vec], T_vec]] = None,
|
|
39
|
-
multiply: Optional[Callable[[float, T_vec], T_vec]] = None,
|
|
40
|
-
ax: Optional[Callable[[float, T_vec], None]] = None,
|
|
41
|
-
axpy: Optional[Callable[[float, T_vec, T_vec], None]] = None,
|
|
42
|
-
copy: Optional[Callable[[T_vec], T_vec]] = None,
|
|
43
|
-
vector_multiply: Optional[Callable[[T_vec, T_vec], T_vec]] = None,
|
|
44
|
-
) -> None:
|
|
45
|
-
"""
|
|
46
|
-
Args:
|
|
47
|
-
order: The order of the Sobolev space, related to its smoothness.
|
|
48
|
-
scale: The characteristic length scale of the Sobolev space.
|
|
49
|
-
dim: The dimension of the space, or of the finite-dimensional
|
|
50
|
-
approximating space.
|
|
51
|
-
to_components: A callable that maps vectors to their component arrays.
|
|
52
|
-
from_components: A callable that maps component arrays to vectors.
|
|
53
|
-
inner_product: A callable that implements the inner product on the space.
|
|
54
|
-
to_dual: A callable that maps a vector to the canonically
|
|
55
|
-
associated dual vector (a LinearForm).
|
|
56
|
-
from_dual: A callable that maps a dual vector back to its
|
|
57
|
-
primal representation in the space.
|
|
58
|
-
add: Custom implementation for vector addition.
|
|
59
|
-
subtract: Custom implementation for vector subtraction.
|
|
60
|
-
multiply: Custom implementation for scalar multiplication.
|
|
61
|
-
axpy: Custom implementation for the mapping `y -> a*x + y`.
|
|
62
|
-
copy: Custom implementation for a deep copy of a vector.
|
|
63
|
-
vector_multiply: Custom implementation for element-wise vector
|
|
64
|
-
multiplication.
|
|
65
|
-
"""
|
|
66
|
-
self._order: float = order
|
|
67
|
-
|
|
68
|
-
if scale <= 0:
|
|
69
|
-
raise ValueError("Scale must be positive")
|
|
70
|
-
self._scale: float = scale
|
|
71
|
-
|
|
72
|
-
super().__init__(
|
|
73
|
-
dim,
|
|
74
|
-
to_components,
|
|
75
|
-
from_components,
|
|
76
|
-
inner_product,
|
|
77
|
-
to_dual,
|
|
78
|
-
from_dual,
|
|
79
|
-
add=add,
|
|
80
|
-
subtract=subtract,
|
|
81
|
-
multiply=multiply,
|
|
82
|
-
ax=ax,
|
|
83
|
-
axpy=axpy,
|
|
84
|
-
copy=copy,
|
|
85
|
-
vector_multiply=vector_multiply,
|
|
86
|
-
)
|
|
87
|
-
|
|
88
52
|
@property
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
53
|
+
@abstractmethod
|
|
54
|
+
def spatial_dimension(self):
|
|
55
|
+
"""The dimension of the symetric space."""
|
|
92
56
|
|
|
93
57
|
@property
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
58
|
+
@abstractmethod
|
|
59
|
+
def dim(self):
|
|
60
|
+
"""The dimension of the Hilbert space."""
|
|
61
|
+
|
|
62
|
+
@abstractmethod
|
|
63
|
+
def to_components(self, u: Any) -> np.ndarray:
|
|
64
|
+
"""Maps a vector `u` to its real component representation."""
|
|
65
|
+
|
|
66
|
+
@abstractmethod
|
|
67
|
+
def from_components(self, c: np.ndarray) -> Any:
|
|
68
|
+
"""Maps a real component vector back to a vector `u`."""
|
|
97
69
|
|
|
98
70
|
@abstractmethod
|
|
99
71
|
def random_point(self) -> Any:
|
|
@@ -109,7 +81,195 @@ class SymmetricSpaceSobolev(HilbertSpace, ABC):
|
|
|
109
81
|
return [self.random_point() for _ in range(n)]
|
|
110
82
|
|
|
111
83
|
@abstractmethod
|
|
112
|
-
def
|
|
84
|
+
def laplacian_eigenvalue(self, k: int | tuple[int, ...]) -> float:
|
|
85
|
+
"""
|
|
86
|
+
Returns the eigenvalue of the Laplacian for a given mode index.
|
|
87
|
+
|
|
88
|
+
The index `k` can be a single integer (e.g., for a circle) or a
|
|
89
|
+
tuple of integers (e.g., for a sphere or torus), depending on the
|
|
90
|
+
geometry of the space.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
k: The index of the eigenvalue to return.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
@abstractmethod
|
|
97
|
+
def eigenfunction_norms(self) -> np.ndarray:
|
|
98
|
+
"""Returns a list of the norms of the eigenfunctions."""
|
|
99
|
+
|
|
100
|
+
@abstractmethod
|
|
101
|
+
def invariant_automorphism(self, f: Callable[[float], float]) -> LinearOperator:
|
|
102
|
+
"""
|
|
103
|
+
Returns an automorphism of the form f(Δ) with f a function
|
|
104
|
+
that is well-defined on the spectrum of the Laplacian, Δ.
|
|
105
|
+
|
|
106
|
+
In order to be well-defined, the function must have appropriate
|
|
107
|
+
growth properties. For example, in an L² space we need f to be bounded.
|
|
108
|
+
In Sobolev spaces Hˢ a more complex condition holds depending on the
|
|
109
|
+
Sobolev order. These conditions on the function are not checked.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
f: A real-valued function that is well-defined on the spectrum
|
|
113
|
+
of the Laplacian.
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
@abstractmethod
|
|
117
|
+
def trace_of_invariant_automorphism(self, f: Callable[[float], float]) -> float:
|
|
118
|
+
"""
|
|
119
|
+
Returns the trace of the automorphism of the form f(Δ) with f a function
|
|
120
|
+
that is well-defined on the spectrum of the Laplacian.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
f: A real-valued function that is well-defined on the spectrum
|
|
124
|
+
of the Laplacian.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
def invariant_gaussian_measure(
|
|
128
|
+
self,
|
|
129
|
+
f: Callable[[float], float],
|
|
130
|
+
):
|
|
131
|
+
"""
|
|
132
|
+
Returns a Gaussian measure with covariance of the form f(Δ).
|
|
133
|
+
|
|
134
|
+
The covariance operator of the resulting measure is `C = f(Δ)`, where `f`
|
|
135
|
+
is a function defined on the spectrum of the Laplacian. To be a valid
|
|
136
|
+
covariance, `f` must be non-negative.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
f: A real-valued, non-negative function that is well-defined on the
|
|
140
|
+
spectrum of the Laplacian, Δ.
|
|
141
|
+
|
|
142
|
+
Notes:
|
|
143
|
+
The implementation assumes the basis for the HilbertSpace consists
|
|
144
|
+
of orthogonal eigenvectors of the Laplacian. The `component_mapping`
|
|
145
|
+
operator used internally handles the mapping from a standard normal
|
|
146
|
+
distribution in R^n to this (potentially non-normalized) eigenbasis.
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
values = self.eigenfunction_norms()
|
|
150
|
+
matrix = diags([np.reciprocal(values)], [0])
|
|
151
|
+
inverse_matrix = diags([values], [0])
|
|
152
|
+
|
|
153
|
+
def mapping(c: np.ndarray) -> np.ndarray:
|
|
154
|
+
return self.from_components(matrix @ c)
|
|
155
|
+
|
|
156
|
+
def adjoint_mapping(u: np.ndarray) -> np.ndarray:
|
|
157
|
+
c = self.to_components(u)
|
|
158
|
+
return inverse_matrix @ c
|
|
159
|
+
|
|
160
|
+
component_mapping = LinearOperator(
|
|
161
|
+
EuclideanSpace(self.dim), self, mapping, adjoint_mapping=adjoint_mapping
|
|
162
|
+
)
|
|
163
|
+
sqrt_covariance = self.invariant_automorphism(lambda k: np.sqrt(f(k)))
|
|
164
|
+
|
|
165
|
+
covariance_factor = sqrt_covariance @ component_mapping
|
|
166
|
+
|
|
167
|
+
return GaussianMeasure(covariance_factor=covariance_factor)
|
|
168
|
+
|
|
169
|
+
def norm_scaled_invariant_gaussian_measure(
|
|
170
|
+
self, f: Callable[[float], float], std: float = 1
|
|
171
|
+
) -> GaussianMeasure:
|
|
172
|
+
"""
|
|
173
|
+
Returns a Gaussian measure whose covariance is proportional to f(Δ) with
|
|
174
|
+
f a function that is well-defined on the spectrum of the Laplacian, Δ.
|
|
175
|
+
|
|
176
|
+
In order to be well-defined, f(Δ) must be trace class, with this implying
|
|
177
|
+
decay conditions on f whose form depends on the form of the symmetric space.
|
|
178
|
+
These conditions on the function are not checked.
|
|
179
|
+
|
|
180
|
+
The measure's covariance is scaled such that the expected value for the
|
|
181
|
+
samples norm is equal to the given standard deviation.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
f: A real-valued function that is well-defined on the spectrum
|
|
185
|
+
of the Laplacian.
|
|
186
|
+
std: The desired standard deviation for the norm of samples.
|
|
187
|
+
"""
|
|
188
|
+
mu = self.invariant_gaussian_measure(f)
|
|
189
|
+
tr = self.trace_of_invariant_automorphism(f)
|
|
190
|
+
return (std / np.sqrt(tr)) * mu
|
|
191
|
+
|
|
192
|
+
def sobolev_kernel_gaussian_measure(self, order: float, scale: float):
|
|
193
|
+
"""
|
|
194
|
+
Returns an invariant Gaussian measure with a Sobolev-type covariance
|
|
195
|
+
equal to (1 + scale^2 * Δ)^-order.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
order: Order parameter for the covariance.
|
|
199
|
+
scale: Scale parameter for the covariance.
|
|
200
|
+
"""
|
|
201
|
+
return self.invariant_gaussian_measure(lambda k: (1 + scale**2 * k) ** (-order))
|
|
202
|
+
|
|
203
|
+
def norm_scaled_sobolev_kernel_gaussian_measure(
|
|
204
|
+
self, order: float, scale: float, std: float = 1
|
|
205
|
+
):
|
|
206
|
+
"""
|
|
207
|
+
Returns an invariant Gaussian measure with a Sobolev-type covariance
|
|
208
|
+
proportional to (1 + scale^2 * Δ)^-order.
|
|
209
|
+
|
|
210
|
+
The measure's covariance is scaled such that the expected value for the
|
|
211
|
+
samples norm is equal to the given standard deviation.
|
|
212
|
+
|
|
213
|
+
Args:
|
|
214
|
+
order: Order parameter for the covariance.
|
|
215
|
+
scale: Scale parameter for the covariance.
|
|
216
|
+
std: The desired standard deviation for the norm of samples.
|
|
217
|
+
"""
|
|
218
|
+
return self.norm_scaled_invariant_gaussian_measure(
|
|
219
|
+
lambda k: (1 + scale**2 * k) ** -order, std
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
def heat_kernel_gaussian_measure(self, scale: float):
|
|
223
|
+
"""
|
|
224
|
+
Returns an invariant Gaussian measure with a heat kernel covariance
|
|
225
|
+
equal to exp(-scale^2 * Δ).
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
scale: Scale parameter for the covariance.
|
|
229
|
+
"""
|
|
230
|
+
return self.invariant_gaussian_measure(lambda k: np.exp(-(scale**2) * k))
|
|
231
|
+
|
|
232
|
+
def norm_scaled_heat_kernel_gaussian_measure(self, scale: float, std: float = 1):
|
|
233
|
+
"""
|
|
234
|
+
Returns an invariant Gaussian measure with a heat kernel covariance
|
|
235
|
+
proportional to exp(-scale^2 * Δ).
|
|
236
|
+
|
|
237
|
+
The measure's covariance is scaled such that the expected value for the
|
|
238
|
+
samples norm is equal to the given standard deviation.
|
|
239
|
+
|
|
240
|
+
Args:
|
|
241
|
+
scale: Scale parameter for the covariance.
|
|
242
|
+
std: The desired standard deviation for the norm of samples.
|
|
243
|
+
"""
|
|
244
|
+
return self.norm_scaled_invariant_gaussian_measure(
|
|
245
|
+
lambda k: np.exp(-(scale**2) * k), std
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class AbstractInvariantSobolevSpace(AbstractInvariantLebesgueSpace):
|
|
250
|
+
"""
|
|
251
|
+
An ABC for Sobolev spaces (Hˢ) on symmetric manifolds.
|
|
252
|
+
|
|
253
|
+
This class extends the Lebesgue space functionality to spaces of functions
|
|
254
|
+
with a specified degree of smoothness (`order`). The primary motivation for
|
|
255
|
+
using a Sobolev space is that for a sufficiently high order, point-wise
|
|
256
|
+
evaluation of a function is a well-defined operation. This is critical for
|
|
257
|
+
linking abstract function fields to discrete data points.
|
|
258
|
+
"""
|
|
259
|
+
|
|
260
|
+
def __init__(self, order: float, scale: float):
|
|
261
|
+
"""
|
|
262
|
+
Args:
|
|
263
|
+
spatial_dimension: The dimension of the space.
|
|
264
|
+
order: The Sobolev order.
|
|
265
|
+
scale: The Sobolev length-scale.
|
|
266
|
+
"""
|
|
267
|
+
|
|
268
|
+
self._order: float = order
|
|
269
|
+
self._scale: float = scale
|
|
270
|
+
|
|
271
|
+
@abstractmethod
|
|
272
|
+
def dirac(self, point: Any) -> LinearForm:
|
|
113
273
|
"""
|
|
114
274
|
Returns the linear functional corresponding to a point evaluation.
|
|
115
275
|
|
|
@@ -118,8 +278,36 @@ class SymmetricSpaceSobolev(HilbertSpace, ABC):
|
|
|
118
278
|
|
|
119
279
|
Args:
|
|
120
280
|
point: The point on the symmetric space at which to base the functional.
|
|
281
|
+
|
|
282
|
+
Raises:
|
|
283
|
+
NotImplementedError: If the Sobolev order is less than n/2, with n the spatial dimension.
|
|
121
284
|
"""
|
|
122
285
|
|
|
286
|
+
@abstractmethod
|
|
287
|
+
def __eq__(self, other: object) -> bool:
|
|
288
|
+
"""
|
|
289
|
+
Checks for mathematical equality with another Sobolev space.
|
|
290
|
+
|
|
291
|
+
Two spaces are considered equal if they are of the same type and have
|
|
292
|
+
the same defining parameters.
|
|
293
|
+
"""
|
|
294
|
+
|
|
295
|
+
@property
|
|
296
|
+
def order(self) -> float:
|
|
297
|
+
"""The Sobolev order."""
|
|
298
|
+
return self._order
|
|
299
|
+
|
|
300
|
+
@property
|
|
301
|
+
def scale(self) -> float:
|
|
302
|
+
"""The Sobolev length-scale."""
|
|
303
|
+
return self._scale
|
|
304
|
+
|
|
305
|
+
def sobolev_function(self, k: float) -> float:
|
|
306
|
+
"""
|
|
307
|
+
Implementation of the relevant Sobolev function for the space.
|
|
308
|
+
"""
|
|
309
|
+
return (1 + self.scale**2 * k) ** self.order
|
|
310
|
+
|
|
123
311
|
def dirac_representation(self, point: Any) -> Any:
|
|
124
312
|
"""
|
|
125
313
|
|
|
@@ -130,19 +318,28 @@ class SymmetricSpaceSobolev(HilbertSpace, ABC):
|
|
|
130
318
|
|
|
131
319
|
Args:
|
|
132
320
|
point: The point on the symmetric space.
|
|
321
|
+
|
|
322
|
+
Raises:
|
|
323
|
+
NotImplementedError: If the Sobolev order is less than n/2, with n the spatial dimension.
|
|
133
324
|
"""
|
|
134
325
|
return self.from_dual(self.dirac(point))
|
|
135
326
|
|
|
136
|
-
def point_evaluation_operator(self, points: List[Any]) ->
|
|
327
|
+
def point_evaluation_operator(self, points: List[Any]) -> LinearOperator:
|
|
137
328
|
"""
|
|
138
329
|
Returns a linear operator that evaluates a function at a list of points.
|
|
139
330
|
|
|
140
331
|
The resulting operator maps a function (a vector in this space) to a
|
|
141
|
-
vector in Euclidean space containing the function's values
|
|
332
|
+
vector in Euclidean space containing the function's values at the
|
|
333
|
+
specified locations. This is the primary mechanism for creating a
|
|
334
|
+
forward operator that links a function field to a set of discrete
|
|
335
|
+
measurements.
|
|
142
336
|
|
|
143
337
|
Args:
|
|
144
338
|
points: A list of points at which to evaluate the functions.
|
|
145
339
|
"""
|
|
340
|
+
if self.order <= self.spatial_dimension / 2:
|
|
341
|
+
raise NotImplementedError("Order must be greater than n/2")
|
|
342
|
+
|
|
146
343
|
dim = len(points)
|
|
147
344
|
matrix = np.zeros((dim, self.dim))
|
|
148
345
|
|
|
@@ -154,90 +351,81 @@ class SymmetricSpaceSobolev(HilbertSpace, ABC):
|
|
|
154
351
|
self, EuclideanSpace(dim), matrix, galerkin=True
|
|
155
352
|
)
|
|
156
353
|
|
|
157
|
-
|
|
158
|
-
def invariant_automorphism(self, f: Callable[[float], float]) -> "LinearOperator":
|
|
354
|
+
def invariant_automorphism(self, f: Callable[[float], float]):
|
|
159
355
|
"""
|
|
160
|
-
Returns an automorphism of the form
|
|
161
|
-
|
|
162
|
-
This uses functional calculus on the Laplace-Beltrami operator to create
|
|
163
|
-
operators that are invariant to the symmetries of the space.
|
|
356
|
+
Returns an invariant automorphism of the form f(Δ) making use of the equivalent
|
|
357
|
+
operator on the underlying Lebesgue space.
|
|
164
358
|
|
|
165
359
|
Args:
|
|
166
|
-
f: A
|
|
360
|
+
f: A real-valued function that is well-defined on the spectrum
|
|
361
|
+
of the Laplacian, Δ.
|
|
167
362
|
"""
|
|
363
|
+
A = self.underlying_space.invariant_automorphism(f)
|
|
364
|
+
return LinearOperator.from_formally_self_adjoint(self, A)
|
|
168
365
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
) -> "GaussianMeasure":
|
|
366
|
+
def point_value_scaled_invariant_gaussian_measure(
|
|
367
|
+
self, f: Callable[[float], float], amplitude: float = 1
|
|
368
|
+
):
|
|
173
369
|
"""
|
|
174
|
-
Returns
|
|
370
|
+
Returns an invariant Gaussian measure with covariance proportional to f(Δ),
|
|
371
|
+
where f must be such that this operator is trace-class.
|
|
175
372
|
|
|
176
|
-
The covariance operator is
|
|
177
|
-
|
|
178
|
-
symmetries of the space.
|
|
373
|
+
The covariance of the operator is scaled such that the standard deviation
|
|
374
|
+
of the point-wise values are equal to the given amplitude.
|
|
179
375
|
|
|
180
376
|
Args:
|
|
181
|
-
f:
|
|
182
|
-
|
|
183
|
-
|
|
377
|
+
f: A real-valued function that is well-defined on the spectrum
|
|
378
|
+
of the Laplacian, Δ.
|
|
379
|
+
amplitude: The desired standard deviation for the pointwise values.
|
|
184
380
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
) -> "GaussianMeasure":
|
|
188
|
-
"""
|
|
189
|
-
Scales an invariant measure to match a target pointwise standard deviation.
|
|
381
|
+
Raises:
|
|
382
|
+
NotImplementedError: If the Sobolev order is less than n/2, with n the spatial dimension.
|
|
190
383
|
|
|
191
|
-
|
|
192
|
-
This method
|
|
193
|
-
variance at a
|
|
194
|
-
|
|
384
|
+
Notes:
|
|
385
|
+
This method applies for symmetric spaces an invariant measures. As a result, the
|
|
386
|
+
pointwise variance is the same at all points. Internally, a random point is chosen
|
|
387
|
+
to carry out the normalisation.
|
|
195
388
|
"""
|
|
196
|
-
|
|
197
|
-
u = self.dirac_representation(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
order: float,
|
|
207
|
-
scale: float,
|
|
208
|
-
amplitude: float,
|
|
209
|
-
/,
|
|
210
|
-
*,
|
|
211
|
-
expectation: Optional[Any] = None,
|
|
212
|
-
) -> "GaussianMeasure":
|
|
389
|
+
point = self.random_point()
|
|
390
|
+
u = self.dirac_representation(point)
|
|
391
|
+
mu = self.invariant_gaussian_measure(f)
|
|
392
|
+
cov = mu.covariance
|
|
393
|
+
var = self.inner_product(cov(u), u)
|
|
394
|
+
return (amplitude / np.sqrt(var)) * mu
|
|
395
|
+
|
|
396
|
+
def point_value_scaled_sobolev_kernel_gaussian_measure(
|
|
397
|
+
self, order: float, scale: float, amplitude: float = 1
|
|
398
|
+
):
|
|
213
399
|
"""
|
|
214
|
-
Returns an invariant Gaussian measure with a Sobolev-type covariance
|
|
400
|
+
Returns an invariant Gaussian measure with a Sobolev-type covariance
|
|
401
|
+
proportional to (1 + scale^2 * Δ)^-order.
|
|
215
402
|
|
|
216
|
-
The covariance operator is
|
|
217
|
-
|
|
403
|
+
The covariance of the operator is scaled such that the standard deviation
|
|
404
|
+
of the point-wise values are equal to the given amplitude.
|
|
218
405
|
|
|
219
406
|
Args:
|
|
220
407
|
order: Order parameter for the covariance.
|
|
221
408
|
scale: Scale parameter for the covariance.
|
|
222
|
-
amplitude: The
|
|
223
|
-
expectation: The expectation (mean field). Defaults to zero.
|
|
409
|
+
amplitude: The desired standard deviation for the pointwise values.
|
|
224
410
|
"""
|
|
225
|
-
|
|
226
|
-
|
|
411
|
+
return self.point_value_scaled_invariant_gaussian_measure(
|
|
412
|
+
lambda k: (1 + scale**2 * k) ** -order, amplitude
|
|
413
|
+
)
|
|
227
414
|
|
|
228
|
-
def
|
|
229
|
-
self, scale: float, amplitude: float
|
|
230
|
-
)
|
|
415
|
+
def point_value_scaled_heat_kernel_gaussian_measure(
|
|
416
|
+
self, scale: float, amplitude: float = 1
|
|
417
|
+
):
|
|
231
418
|
"""
|
|
232
|
-
Returns an invariant Gaussian measure with a heat
|
|
419
|
+
Returns an invariant Gaussian measure with a heat-kernel covariance
|
|
420
|
+
proportional to exp(-scale^2 * Δ).
|
|
233
421
|
|
|
234
|
-
The covariance operator is
|
|
235
|
-
|
|
422
|
+
The covariance of the operator is scaled such that the standard deviation
|
|
423
|
+
of the point-wise values are equal to the given amplitude.
|
|
236
424
|
|
|
237
425
|
Args:
|
|
238
426
|
scale: Scale parameter for the covariance.
|
|
239
|
-
amplitude: The
|
|
240
|
-
expectation: The expectation (mean field). Defaults to zero.
|
|
427
|
+
amplitude: The desired standard deviation for the pointwise values.
|
|
241
428
|
"""
|
|
242
|
-
|
|
243
|
-
|
|
429
|
+
return self.point_value_scaled_invariant_gaussian_measure(
|
|
430
|
+
lambda k: np.exp(-(scale**2) * k), amplitude
|
|
431
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pygeoinf
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: A package for solving geophysical inference and inverse problems
|
|
5
5
|
License: BSD-3-Clause
|
|
6
6
|
Author: David Al-Attar and Dan Heathcote
|
|
@@ -16,7 +16,6 @@ Requires-Dist: numpy (>=1.26.0)
|
|
|
16
16
|
Requires-Dist: pyqt6 (>=6.0.0)
|
|
17
17
|
Requires-Dist: pyshtools (>=4.0.0)
|
|
18
18
|
Requires-Dist: scipy (>=1.0.0)
|
|
19
|
-
Requires-Dist: snakeviz (>=2.2.2,<3.0.0)
|
|
20
19
|
Description-Content-Type: text/markdown
|
|
21
20
|
|
|
22
21
|
# pygeoinf: A Python Library for Geophysical Inference
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
pygeoinf/__init__.py,sha256=uYRwiHKi4nvzUBwQJxNdt8OZodFQ_nj5rUv2YkDXL9Q,1185
|
|
2
|
+
pygeoinf/direct_sum.py,sha256=r0h-3bK6RQiOMoq086oupYaXgUM4pFIV8XNKOB2q9BE,17095
|
|
3
|
+
pygeoinf/forward_problem.py,sha256=RnnVBMg8Ih7TqZylfSkQ7pdHEowEfCkTiXiKFrxBpnM,9754
|
|
4
|
+
pygeoinf/gaussian_measure.py,sha256=SFnHmEjpcrUy09AfO3fXLLB_SaGwA9oc5PU630e3hNM,22826
|
|
5
|
+
pygeoinf/hilbert_space.py,sha256=42RSYoIPf0hruyysBVoeJGmsmDtTrpaet5YMZnxwgys,22429
|
|
6
|
+
pygeoinf/inversion.py,sha256=p9k_iDVgJGLM1cGlT-0rgRwqdYVdsYC_euTXZk3kuOc,3199
|
|
7
|
+
pygeoinf/linear_bayesian.py,sha256=aIOzTZbjJtdtwHKh5e01iS8iMiyr8XuwGx91udS3VK4,9624
|
|
8
|
+
pygeoinf/linear_forms.py,sha256=Uizipi67i1Sd6m0TzsrJd99Xreo_6V8Db0gMy76fG6g,5953
|
|
9
|
+
pygeoinf/linear_optimisation.py,sha256=7lklTRRBGkz8M9WsfvkDl-eoGkc4Ty7BOJq7LWkdxCg,11091
|
|
10
|
+
pygeoinf/linear_solvers.py,sha256=P9SEjZ1LZdulr2KQrZojbvdCtAm--hMd4EArSu73L34,12154
|
|
11
|
+
pygeoinf/operators.py,sha256=JPDrdLSnM-Y5_CWJ58WDvHBzo3hPoFoUoAOS63QFJmc,32272
|
|
12
|
+
pygeoinf/random_matrix.py,sha256=_XVwXqM_c0SMpy6JU-8IboXpotug6dDDHKdSPAJpH7c,7788
|
|
13
|
+
pygeoinf/symmetric_space/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
pygeoinf/symmetric_space/circle.py,sha256=0EHPg2FcvWTOvCb8ualCW0uUp8RuUNfQ7oK6NHXtG1Q,17552
|
|
15
|
+
pygeoinf/symmetric_space/sphere.py,sha256=vKwvTa-9GMNlN-LBUWaEsZ8vM-dZtQtT71UPDSXZufY,20309
|
|
16
|
+
pygeoinf/symmetric_space/symmetric_space.py,sha256=YkRjHucc2cO7IAoyJS5KMdiRBuytRpUfTUsVMHBPZYs,16146
|
|
17
|
+
pygeoinf-1.1.0.dist-info/LICENSE,sha256=GrTQnKJemVi69FSbHprq60KN0OJGsOSR-joQoTq-oD8,1501
|
|
18
|
+
pygeoinf-1.1.0.dist-info/METADATA,sha256=r9MgMBiluq7IGB0ts7Nxxsz1bAeL5tOE2iYskaWvWe8,14375
|
|
19
|
+
pygeoinf-1.1.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
20
|
+
pygeoinf-1.1.0.dist-info/RECORD,,
|