Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Neel Shah
NIFTy
Commits
29ae4690
Commit
29ae4690
authored
Oct 11, 2017
by
Jakob Knollmueller
Browse files
fixed wiener_filter_via_hamiltonian variance calculation
parent
4459c75b
Changes
1
Hide whitespace changes
Inline
Side-by-side
demos/wiener_filter_via_hamiltonian.py
View file @
29ae4690
...
...
@@ -11,7 +11,7 @@ from mpi4py import MPI
comm
=
MPI
.
COMM_WORLD
rank
=
comm
.
rank
d2o
.
random
.
seed
(
42
)
#
d2o.random.seed(42)
class
AdjointFFTResponse
(
LinearOperator
):
...
...
@@ -71,7 +71,7 @@ if __name__ == "__main__":
# Choosing the measurement instrument
# Instrument = SmoothingOperator(s_space, sigma=0.05)
Instrument
=
DiagonalOperator
(
s_space
,
diagonal
=
1.
)
#
Instrument._diagonal.val[
200:400, 200:40
0] = 0
Instrument
.
_diagonal
.
val
[
64
:
80
,
32
:
8
0
]
=
0
.
# Adding a harmonic transformation to the instrument
R
=
AdjointFFTResponse
(
fft
,
Instrument
)
...
...
@@ -123,8 +123,10 @@ if __name__ == "__main__":
D0
=
energy
.
curvature
# Solving the problem analytically
# m0 = D0.inverse_times(j)
m0
=
D0
.
inverse_times
(
j
)
energy
,
convergence
=
minimizer
(
energy
)
m
=
energy
.
position
D
=
energy
.
curvature
m
=
minimizer
(
energy
)[
0
].
position
plotter
=
plotting
.
RG2DPlotter
()
...
...
@@ -132,13 +134,15 @@ if __name__ == "__main__":
plotter
(
fft
.
inverse_times
(
m
),
path
=
'm.html'
)
#
sample_variance = Field(s
h.domain
, val=0.)
#
sample_mean = Field(s
h.domain
, val=0.)
sample_variance
=
Field
(
s
_space
,
val
=
0.
)
sample_mean
=
Field
(
s
_space
,
val
=
0.
)
# # sampling the uncertainty map
# n_samples = 10
# for i in range(n_samples):
# sample = fft(sugar.generate_posterior_sample(0., D0))
# sample_variance += sample**2
# sample_mean += sample
# variance = (sample_variance - sample_mean**2)/n_samples
# sampling the uncertainty map
n_samples
=
50
for
i
in
range
(
n_samples
):
sample
=
fft
.
adjoint_times
(
sugar
.
generate_posterior_sample
(
m
,
D
))
sample_variance
+=
sample
**
2
sample_mean
+=
sample
sample_mean
/=
n_samples
sample_variance
/=
n_samples
variance
=
(
sample_variance
-
sample_mean
**
2
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment