Commit a9652e2c authored by Philipp Arras's avatar Philipp Arras
Browse files

Add approximation stuff to nifty

parent 3e46f282
Pipeline #52283 passed with stages
in 8 minutes and 21 seconds
......@@ -54,7 +54,7 @@ from .operators.energy_operators import (
from .operators.convolution_operators import FuncConvolutionOperator
from .probing import probe_with_posterior_samples, probe_diagonal, \
StatCalculator, approximation2endo
from .minimization.line_search import LineSearch
from .minimization.iteration_controllers import (
......@@ -134,3 +134,18 @@ def probe_diagonal(op, nprobes, random_type="pm1"):
x = from_random(random_type, op.domain)
return sc.mean
def approximation2endo(op, nsamples):
from .sugar import from_global_data
from .multi_field import MultiField
sc = StatCalculator()
for _ in range(nsamples):
approx = sc.var
dct = approx.to_dict()
for kk in dct:
foo = dct[kk].to_global_data_rw()
foo[foo == 0] = 1
dct[kk] = from_global_data(dct[kk].domain, foo)
return MultiField.from_dict(dct)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment