Commit e4da642c authored by Sebastian Heimann's avatar Sebastian Heimann

bugfix: nbootstrap

parent 44d69ace
......@@ -361,6 +361,7 @@ def draw_jointpar_figures(
msize = 1.5
problem = model.problem
solver = model.solver
if not problem:
return []
......@@ -379,7 +380,8 @@ def draw_jointpar_figures(
xref = problem.get_xref()
if ibootstrap is not None:
gms = problem.bootstrap_misfits(model.misfits, ibootstrap)
gms = problem.bootstrap_misfits(
model.misfits, solver.nbootstrap, ibootstrap)
else:
gms = problem.global_misfits(model.misfits)
......@@ -826,7 +828,7 @@ def draw_bootstrap_figure(model, plt):
ibests = []
for ibootstrap in range(solver.nbootstrap):
bms = problem.bootstrap_misfits(
model.misfits, ibootstrap, solver.nbootstrap)
model.misfits, solver.nbootstrap, ibootstrap)
isort_bms = num.argsort(bms)[::-1]
ibests.append(isort_bms[-1])
......
......@@ -286,8 +286,7 @@ class Problem(Object):
else:
self.raise_invalid_norm_exponent()
def bootstrap_misfit(self, ms, ns, ibootstrap=None, nbootstraps=None):
# Should this be nbootstrap?
def bootstrap_misfit(self, ms, ns, nbootstrap, ibootstrap=None):
exp, root = self.get_norm_functions()
w = self.get_target_weights() * self.inter_group_weights(ns)
......@@ -296,10 +295,10 @@ class Problem(Object):
num.nansum(exp(w*ms[num.newaxis, :]), axis=1) /
num.nansum(exp(w*ns[num.newaxis, :]), axis=1))
w *= self.get_bootstrap_weights(ibootstrap)
w *= self.get_bootstrap_weights(nbootstrap, ibootstrap)
return root(num.nansum(exp(w*ms)) / num.nansum(exp(w*ns)))
def bootstrap_misfits(self, misfits, ibootstrap, nbootstraps):
def bootstrap_misfits(self, misfits, nbootstrap, ibootstrap=None):
exp, root = self.get_norm_functions()
w = self.get_bootstrap_weights(
......
......@@ -66,7 +66,6 @@ class DoubleDCProblem(Problem):
dependants = []
distance_min = Float.T(default=0.0)
nbootstrap = Int.T(default=100)
def get_source(self, x):
d = self.get_parameter_dict(x)
......
......@@ -292,7 +292,7 @@ def solve(problem,
return
gm = problem.global_misfit(ms, ns)
bms = problem.bootstrap_misfit(ms, ns)
bms = problem.bootstrap_misfit(ms, ns, nbootstrap)
chains_m[0, nlinks] = gm
chains_m[1:, nlinks] = bms
......
Markdown is supported
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