CUQIpy 1.0.0.post0.dev91__py3-none-any.whl → 1.0.0.post0.dev127__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.
Potentially problematic release.
This version of CUQIpy might be problematic. Click here for more details.
- {CUQIpy-1.0.0.post0.dev91.dist-info → CUQIpy-1.0.0.post0.dev127.dist-info}/METADATA +1 -1
- {CUQIpy-1.0.0.post0.dev91.dist-info → CUQIpy-1.0.0.post0.dev127.dist-info}/RECORD +9 -8
- cuqi/_version.py +3 -3
- cuqi/experimental/mcmc/__init__.py +1 -0
- cuqi/experimental/mcmc/_rto.py +275 -0
- cuqi/experimental/mcmc/_sampler.py +5 -0
- {CUQIpy-1.0.0.post0.dev91.dist-info → CUQIpy-1.0.0.post0.dev127.dist-info}/LICENSE +0 -0
- {CUQIpy-1.0.0.post0.dev91.dist-info → CUQIpy-1.0.0.post0.dev127.dist-info}/WHEEL +0 -0
- {CUQIpy-1.0.0.post0.dev91.dist-info → CUQIpy-1.0.0.post0.dev127.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: CUQIpy
|
|
3
|
-
Version: 1.0.0.post0.
|
|
3
|
+
Version: 1.0.0.post0.dev127
|
|
4
4
|
Summary: Computational Uncertainty Quantification for Inverse problems in Python
|
|
5
5
|
Maintainer-email: "Nicolai A. B. Riis" <nabr@dtu.dk>, "Jakob S. Jørgensen" <jakj@dtu.dk>, "Amal M. Alghamdi" <amaal@dtu.dk>, Chao Zhang <chaz@dtu.dk>
|
|
6
6
|
License: Apache License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cuqi/__init__.py,sha256=LsGilhl-hBLEn6Glt8S_l0OJzAA1sKit_rui8h-D-p0,488
|
|
2
2
|
cuqi/_messages.py,sha256=fzEBrZT2kbmfecBBPm7spVu7yHdxGARQB4QzXhJbCJ0,415
|
|
3
|
-
cuqi/_version.py,sha256=
|
|
3
|
+
cuqi/_version.py,sha256=2GhcRA-eAhvzsZ7hWqzmLdIV7UEkRWfrTcDXqFBbrWE,510
|
|
4
4
|
cuqi/config.py,sha256=wcYvz19wkeKW2EKCGIKJiTpWt5kdaxyt4imyRkvtTRA,526
|
|
5
5
|
cuqi/diagnostics.py,sha256=5OrbJeqpynqRXOe5MtOKKhe7EAVdOEpHIqHnlMW9G_c,3029
|
|
6
6
|
cuqi/array/__init__.py,sha256=-EeiaiWGNsE3twRS4dD814BIlfxEsNkTCZUc5gjOXb0,30
|
|
@@ -32,12 +32,13 @@ cuqi/distribution/_normal.py,sha256=UeoTtGDT7YSf4ZNo2amlVF9K-YQpYbf8q76jcRJTVFw,
|
|
|
32
32
|
cuqi/distribution/_posterior.py,sha256=zAfL0GECxekZ2lBt1W6_LN0U_xskMwK4VNce5xAF7ig,5018
|
|
33
33
|
cuqi/distribution/_uniform.py,sha256=7xJmCZH_LPhuGkwEDGh-_CTtzcWKrXMOxtTJUFb7Ydo,1607
|
|
34
34
|
cuqi/experimental/__init__.py,sha256=vhZvyMX6rl8Y0haqCzGLPz6PSUKyu75XMQbeDHqTTrw,83
|
|
35
|
-
cuqi/experimental/mcmc/__init__.py,sha256=
|
|
35
|
+
cuqi/experimental/mcmc/__init__.py,sha256=vVnohcm4EIUwbp1sr3LbB0BkXO8jyZsbiKMJmIgetYY,314
|
|
36
36
|
cuqi/experimental/mcmc/_cwmh.py,sha256=G-8YjMqPraZm1Pm3n6scFkpa65gdtI1WTQxlL21etEI,8066
|
|
37
37
|
cuqi/experimental/mcmc/_langevin_algorithm.py,sha256=ckVHDXLaw8hsUaOAFAEs7bL2Ny7W1QBKSc4AAC-TCis,9986
|
|
38
38
|
cuqi/experimental/mcmc/_mh.py,sha256=AslackZJ3hPUNQfy70Fh9WoRPtcsHGqulI0LQgGHBus,3477
|
|
39
39
|
cuqi/experimental/mcmc/_pcn.py,sha256=ma3pFqFgOmE7woZ41B5CGccKEuaacJPTmKvSEQhvtzs,3981
|
|
40
|
-
cuqi/experimental/mcmc/
|
|
40
|
+
cuqi/experimental/mcmc/_rto.py,sha256=nQHpSnUlE65TXBnGFk88JLawR44af2Rtle0oFCGYgaQ,11540
|
|
41
|
+
cuqi/experimental/mcmc/_sampler.py,sha256=s-15bElbSZFHJlaV9gmiwk-UAneQEU9W-y5tLy_NMCU,11197
|
|
41
42
|
cuqi/geometry/__init__.py,sha256=Tz1WGzZBY-QGH3c0GiyKm9XHN8MGGcnU6TUHLZkzB3o,842
|
|
42
43
|
cuqi/geometry/_geometry.py,sha256=WYFC-4_VBTW73b2ldsnfGYKvdSiCE8plr89xTSmkadg,46804
|
|
43
44
|
cuqi/implicitprior/__init__.py,sha256=ZRZ9fgxgEl5n0A9F7WCl1_jid-GUiC8ZLkyTmGQmFlY,100
|
|
@@ -74,8 +75,8 @@ cuqi/testproblem/_testproblem.py,sha256=x769LwwRdJdzIiZkcQUGb_5-vynNTNALXWKato7s
|
|
|
74
75
|
cuqi/utilities/__init__.py,sha256=EfxHLdsyDNugbmbzs43nV_AeKcycM9sVBjG9WZydagA,351
|
|
75
76
|
cuqi/utilities/_get_python_variable_name.py,sha256=QwlBVj2koJRA8s8pWd554p7-ElcI7HUwY32HknaR92E,1827
|
|
76
77
|
cuqi/utilities/_utilities.py,sha256=At3DOXRdF3GwLkVcM2FXooGyjAGfPkIM0bRzhTfLmWk,8046
|
|
77
|
-
CUQIpy-1.0.0.post0.
|
|
78
|
-
CUQIpy-1.0.0.post0.
|
|
79
|
-
CUQIpy-1.0.0.post0.
|
|
80
|
-
CUQIpy-1.0.0.post0.
|
|
81
|
-
CUQIpy-1.0.0.post0.
|
|
78
|
+
CUQIpy-1.0.0.post0.dev127.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
|
|
79
|
+
CUQIpy-1.0.0.post0.dev127.dist-info/METADATA,sha256=bHtJEgkhpP_C50jwE7SwIpOY0Hm48V2qMKy_v6k0SiU,18393
|
|
80
|
+
CUQIpy-1.0.0.post0.dev127.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
81
|
+
CUQIpy-1.0.0.post0.dev127.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
|
|
82
|
+
CUQIpy-1.0.0.post0.dev127.dist-info/RECORD,,
|
cuqi/_version.py
CHANGED
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2024-04-
|
|
11
|
+
"date": "2024-04-05T11:26:24+0200",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "1.0.0.post0.
|
|
14
|
+
"full-revisionid": "476cc08200034336b46144fac4c819f8298fa587",
|
|
15
|
+
"version": "1.0.0.post0.dev127"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import scipy as sp
|
|
2
|
+
from scipy.linalg.interpolative import estimate_spectral_norm
|
|
3
|
+
from scipy.sparse.linalg import LinearOperator as scipyLinearOperator
|
|
4
|
+
import numpy as np
|
|
5
|
+
import cuqi
|
|
6
|
+
from cuqi.solver import CGLS, FISTA
|
|
7
|
+
from cuqi.experimental.mcmc import SamplerNew
|
|
8
|
+
from cuqi.array import CUQIarray
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class LinearRTONew(SamplerNew):
|
|
12
|
+
"""
|
|
13
|
+
Linear RTO (Randomize-Then-Optimize) sampler.
|
|
14
|
+
|
|
15
|
+
Samples posterior related to the inverse problem with Gaussian likelihood and prior, and where the forward model is Linear.
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
------------
|
|
19
|
+
target : `cuqi.distribution.Posterior`, `cuqi.distribution.MultipleLikelihoodPosterior` or 5-dimensional tuple.
|
|
20
|
+
If target is of type cuqi.distribution.Posterior or cuqi.distribution.MultipleLikelihoodPosterior, it represents the posterior distribution.
|
|
21
|
+
If target is a 5-dimensional tuple, it assumes the following structure:
|
|
22
|
+
(data, model, L_sqrtprec, P_mean, P_sqrtrec)
|
|
23
|
+
|
|
24
|
+
Here:
|
|
25
|
+
data: is a m-dimensional numpy array containing the measured data.
|
|
26
|
+
model: is a m by n dimensional matrix or LinearModel representing the forward model.
|
|
27
|
+
L_sqrtprec: is the squareroot of the precision matrix of the Gaussian likelihood.
|
|
28
|
+
P_mean: is the prior mean.
|
|
29
|
+
P_sqrtprec: is the squareroot of the precision matrix of the Gaussian mean.
|
|
30
|
+
|
|
31
|
+
initial_point : `np.ndarray`
|
|
32
|
+
Initial point for the sampler. *Optional*.
|
|
33
|
+
|
|
34
|
+
maxit : int
|
|
35
|
+
Maximum number of iterations of the inner CGLS solver. *Optional*.
|
|
36
|
+
|
|
37
|
+
tol : float
|
|
38
|
+
Tolerance of the inner CGLS solver. *Optional*.
|
|
39
|
+
|
|
40
|
+
callback : callable, *Optional*
|
|
41
|
+
If set this function will be called after every sample.
|
|
42
|
+
The signature of the callback function is `callback(sample, sample_index)`,
|
|
43
|
+
where `sample` is the current sample and `sample_index` is the index of the sample.
|
|
44
|
+
An example is shown in demos/demo31_callback.py.
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
def __init__(self, target, initial_point=None, maxit=10, tol=1e-6, **kwargs):
|
|
48
|
+
|
|
49
|
+
super().__init__(target=target, initial_point=initial_point, **kwargs)
|
|
50
|
+
|
|
51
|
+
if initial_point is None: #TODO: Replace later with a getter
|
|
52
|
+
self.initial_point = np.zeros(self.dim)
|
|
53
|
+
|
|
54
|
+
self.current_point = self.initial_point
|
|
55
|
+
self._acc = [1] # TODO. Check if we need this
|
|
56
|
+
|
|
57
|
+
# Other parameters
|
|
58
|
+
self.maxit = maxit
|
|
59
|
+
self.tol = tol
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def prior(self):
|
|
63
|
+
return self.target.prior
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def likelihood(self):
|
|
67
|
+
return self.target.likelihood
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def likelihoods(self):
|
|
71
|
+
if isinstance(self.target, cuqi.distribution.Posterior):
|
|
72
|
+
return [self.target.likelihood]
|
|
73
|
+
elif isinstance(self.target, cuqi.distribution.MultipleLikelihoodPosterior):
|
|
74
|
+
return self.target.likelihoods
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def model(self):
|
|
78
|
+
return self.target.model
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def data(self):
|
|
82
|
+
return self.target.data
|
|
83
|
+
|
|
84
|
+
@SamplerNew.target.setter
|
|
85
|
+
def target(self, value):
|
|
86
|
+
""" Set the target density. Runs validation of the target. """
|
|
87
|
+
# Accept tuple of inputs and construct posterior
|
|
88
|
+
if isinstance(value, tuple) and len(value) == 5:
|
|
89
|
+
# Structure (data, model, L_sqrtprec, P_mean, P_sqrtprec)
|
|
90
|
+
data = value[0]
|
|
91
|
+
model = value[1]
|
|
92
|
+
L_sqrtprec = value[2]
|
|
93
|
+
P_mean = value[3]
|
|
94
|
+
P_sqrtprec = value[4]
|
|
95
|
+
|
|
96
|
+
# If numpy matrix convert to CUQI model
|
|
97
|
+
if isinstance(model, np.ndarray) and len(model.shape) == 2:
|
|
98
|
+
model = cuqi.model.LinearModel(model)
|
|
99
|
+
|
|
100
|
+
# Check model input
|
|
101
|
+
if not isinstance(model, cuqi.model.LinearModel):
|
|
102
|
+
raise TypeError("Model needs to be cuqi.model.LinearModel or matrix")
|
|
103
|
+
|
|
104
|
+
# Likelihood
|
|
105
|
+
L = cuqi.distribution.Gaussian(model, sqrtprec=L_sqrtprec).to_likelihood(data)
|
|
106
|
+
|
|
107
|
+
# Prior TODO: allow multiple priors stacked
|
|
108
|
+
#if isinstance(P_mean, list) and isinstance(P_sqrtprec, list):
|
|
109
|
+
# P = cuqi.distribution.JointGaussianSqrtPrec(P_mean, P_sqrtprec)
|
|
110
|
+
#else:
|
|
111
|
+
P = cuqi.distribution.Gaussian(P_mean, sqrtprec=P_sqrtprec)
|
|
112
|
+
|
|
113
|
+
# Construct posterior
|
|
114
|
+
value = cuqi.distribution.Posterior(L, P)
|
|
115
|
+
super(LinearRTONew, type(self)).target.fset(self, value)
|
|
116
|
+
self._precompute()
|
|
117
|
+
|
|
118
|
+
def _precompute(self):
|
|
119
|
+
L1 = [likelihood.distribution.sqrtprec for likelihood in self.likelihoods]
|
|
120
|
+
L2 = self.prior.sqrtprec
|
|
121
|
+
L2mu = self.prior.sqrtprecTimesMean
|
|
122
|
+
|
|
123
|
+
# pre-computations
|
|
124
|
+
self.n = self.prior.dim
|
|
125
|
+
self.b_tild = np.hstack([L@likelihood.data for (L, likelihood) in zip(L1, self.likelihoods)]+ [L2mu])
|
|
126
|
+
|
|
127
|
+
callability = [callable(likelihood.model) for likelihood in self.likelihoods]
|
|
128
|
+
notcallability = [not c for c in callability]
|
|
129
|
+
if all(notcallability):
|
|
130
|
+
self.M = sp.sparse.vstack([L@likelihood.model for (L, likelihood) in zip(L1, self.likelihoods)] + [L2])
|
|
131
|
+
elif all(callability):
|
|
132
|
+
# in this case, model is a function doing forward and backward operations
|
|
133
|
+
def M(x, flag):
|
|
134
|
+
if flag == 1:
|
|
135
|
+
out1 = [L @ likelihood.model.forward(x) for (L, likelihood) in zip(L1, self.likelihoods)]
|
|
136
|
+
out2 = L2 @ x
|
|
137
|
+
out = np.hstack(out1 + [out2])
|
|
138
|
+
elif flag == 2:
|
|
139
|
+
idx_start = 0
|
|
140
|
+
idx_end = 0
|
|
141
|
+
out1 = np.zeros(self.n)
|
|
142
|
+
for likelihood in self.likelihoods:
|
|
143
|
+
idx_end += len(likelihood.data)
|
|
144
|
+
out1 += likelihood.model.adjoint(likelihood.distribution.sqrtprec.T@x[idx_start:idx_end])
|
|
145
|
+
idx_start = idx_end
|
|
146
|
+
out2 = L2.T @ x[idx_end:]
|
|
147
|
+
out = out1 + out2
|
|
148
|
+
return out
|
|
149
|
+
self.M = M
|
|
150
|
+
else:
|
|
151
|
+
raise TypeError("All likelihoods need to be callable or none need to be callable.")
|
|
152
|
+
|
|
153
|
+
def step(self):
|
|
154
|
+
y = self.b_tild + np.random.randn(len(self.b_tild))
|
|
155
|
+
sim = CGLS(self.M, y, self.current_point, self.maxit, self.tol)
|
|
156
|
+
self.current_point, _ = sim.solve()
|
|
157
|
+
acc = 1
|
|
158
|
+
return acc
|
|
159
|
+
|
|
160
|
+
def tune(self, skip_len, update_count):
|
|
161
|
+
pass
|
|
162
|
+
|
|
163
|
+
def validate_target(self):
|
|
164
|
+
# Check target type
|
|
165
|
+
if not isinstance(self.target, (cuqi.distribution.Posterior, cuqi.distribution.MultipleLikelihoodPosterior)):
|
|
166
|
+
raise ValueError(f"To initialize an object of type {self.__class__}, 'target' need to be of type 'cuqi.distribution.Posterior' or 'cuqi.distribution.MultipleLikelihoodPosterior'.")
|
|
167
|
+
|
|
168
|
+
# Check Linear model and Gaussian likelihood(s)
|
|
169
|
+
if isinstance(self.target, cuqi.distribution.Posterior):
|
|
170
|
+
if not isinstance(self.model, cuqi.model.LinearModel):
|
|
171
|
+
raise TypeError("Model needs to be linear")
|
|
172
|
+
|
|
173
|
+
if not hasattr(self.likelihood.distribution, "sqrtprec"):
|
|
174
|
+
raise TypeError("Distribution in Likelihood must contain a sqrtprec attribute")
|
|
175
|
+
|
|
176
|
+
elif isinstance(self.target, cuqi.distribution.MultipleLikelihoodPosterior): # Elif used for further alternatives, e.g., stacked posterior
|
|
177
|
+
for likelihood in self.likelihoods:
|
|
178
|
+
if not isinstance(likelihood.model, cuqi.model.LinearModel):
|
|
179
|
+
raise TypeError("Model needs to be linear")
|
|
180
|
+
|
|
181
|
+
if not hasattr(likelihood.distribution, "sqrtprec"):
|
|
182
|
+
raise TypeError("Distribution in Likelihood must contain a sqrtprec attribute")
|
|
183
|
+
|
|
184
|
+
# Check Gaussian prior
|
|
185
|
+
if not hasattr(self.prior, "sqrtprec"):
|
|
186
|
+
raise TypeError("prior must contain a sqrtprec attribute")
|
|
187
|
+
|
|
188
|
+
if not hasattr(self.prior, "sqrtprecTimesMean"):
|
|
189
|
+
raise TypeError("Prior must contain a sqrtprecTimesMean attribute")
|
|
190
|
+
|
|
191
|
+
def get_state(self): #TODO: LinearRTO only need initial_point for reproducibility?
|
|
192
|
+
return {'sampler_type': 'LinearRTO'}
|
|
193
|
+
|
|
194
|
+
def set_state(self, state): #TODO: LinearRTO only need initial_point for reproducibility?
|
|
195
|
+
pass
|
|
196
|
+
|
|
197
|
+
class RegularizedLinearRTONew(LinearRTONew):
|
|
198
|
+
"""
|
|
199
|
+
Regularized Linear RTO (Randomize-Then-Optimize) sampler.
|
|
200
|
+
|
|
201
|
+
Samples posterior related to the inverse problem with Gaussian likelihood and implicit Gaussian prior, and where the forward model is Linear.
|
|
202
|
+
|
|
203
|
+
Parameters
|
|
204
|
+
------------
|
|
205
|
+
target : `cuqi.distribution.Posterior`
|
|
206
|
+
See `cuqi.sampler.LinearRTO`
|
|
207
|
+
|
|
208
|
+
initial_point : `np.ndarray`
|
|
209
|
+
Initial point for the sampler. *Optional*.
|
|
210
|
+
|
|
211
|
+
maxit : int
|
|
212
|
+
Maximum number of iterations of the inner FISTA solver. *Optional*.
|
|
213
|
+
|
|
214
|
+
stepsize : string or float
|
|
215
|
+
If stepsize is a string and equals either "automatic", then the stepsize is automatically estimated based on the spectral norm.
|
|
216
|
+
If stepsize is a float, then this stepsize is used.
|
|
217
|
+
|
|
218
|
+
abstol : float
|
|
219
|
+
Absolute tolerance of the inner FISTA solver. *Optional*.
|
|
220
|
+
|
|
221
|
+
adaptive : bool
|
|
222
|
+
If True, FISTA is used as inner solver, otherwise ISTA is used. *Optional*.
|
|
223
|
+
|
|
224
|
+
callback : callable, *Optional*
|
|
225
|
+
If set this function will be called after every sample.
|
|
226
|
+
The signature of the callback function is `callback(sample, sample_index)`,
|
|
227
|
+
where `sample` is the current sample and `sample_index` is the index of the sample.
|
|
228
|
+
An example is shown in demos/demo31_callback.py.
|
|
229
|
+
|
|
230
|
+
"""
|
|
231
|
+
def __init__(self, target, initial_point=None, maxit=100, stepsize="automatic", abstol=1e-10, adaptive=True, **kwargs):
|
|
232
|
+
|
|
233
|
+
super().__init__(target=target, initial_point=initial_point, **kwargs)
|
|
234
|
+
|
|
235
|
+
# Other parameters
|
|
236
|
+
self.stepsize = stepsize
|
|
237
|
+
self.abstol = abstol
|
|
238
|
+
self.adaptive = adaptive
|
|
239
|
+
self.proximal = target.prior.proximal
|
|
240
|
+
self._stepsize = self._choose_stepsize()
|
|
241
|
+
self.maxit = maxit
|
|
242
|
+
|
|
243
|
+
@LinearRTONew.target.setter
|
|
244
|
+
def target(self, value):
|
|
245
|
+
if not callable(value.prior.proximal):
|
|
246
|
+
raise TypeError("Projector needs to be callable")
|
|
247
|
+
return super(RegularizedLinearRTONew, type(self)).target.fset(self, value)
|
|
248
|
+
|
|
249
|
+
def _choose_stepsize(self):
|
|
250
|
+
if isinstance(self.stepsize, str):
|
|
251
|
+
if self.stepsize in ["automatic"]:
|
|
252
|
+
if not callable(self.M):
|
|
253
|
+
M_op = scipyLinearOperator(self.M.shape, matvec = lambda v: self.M@v, rmatvec = lambda w: self.M.T@w)
|
|
254
|
+
else:
|
|
255
|
+
M_op = scipyLinearOperator((len(self.b_tild), self.n), matvec = lambda v: self.M(v,1), rmatvec = lambda w: self.M(w,2))
|
|
256
|
+
|
|
257
|
+
_stepsize = 0.99/(estimate_spectral_norm(M_op)**2)
|
|
258
|
+
# print(f"Estimated stepsize for regularized Linear RTO: {_stepsize}")
|
|
259
|
+
else:
|
|
260
|
+
raise ValueError("Stepsize choice not supported")
|
|
261
|
+
else:
|
|
262
|
+
_stepsize = self.stepsize
|
|
263
|
+
return _stepsize
|
|
264
|
+
|
|
265
|
+
@property
|
|
266
|
+
def prior(self):
|
|
267
|
+
return self.target.prior.gaussian
|
|
268
|
+
|
|
269
|
+
def step(self):
|
|
270
|
+
y = self.b_tild + np.random.randn(len(self.b_tild))
|
|
271
|
+
sim = FISTA(self.M, y, self.current_point, self.proximal,
|
|
272
|
+
maxit = self.maxit, stepsize = self._stepsize, abstol = self.abstol, adaptive = self.adaptive)
|
|
273
|
+
self.current_point, _ = sim.solve()
|
|
274
|
+
acc = 1
|
|
275
|
+
return acc
|
|
@@ -83,6 +83,11 @@ class SamplerNew(ABC):
|
|
|
83
83
|
""" Return the initial point of the sampler. This is always the first sample. """
|
|
84
84
|
return self._samples[0]
|
|
85
85
|
|
|
86
|
+
@initial_point.setter
|
|
87
|
+
def initial_point(self, value):
|
|
88
|
+
""" Set the initial point of the sampler. """
|
|
89
|
+
self._samples[0] = value
|
|
90
|
+
|
|
86
91
|
@property
|
|
87
92
|
def dim(self):
|
|
88
93
|
""" Dimension of the target density. """
|
|
File without changes
|
|
File without changes
|
|
File without changes
|