Skip to content

Commit 8b76273

Browse files
committed
Handle unbounded n_s in 1D llh scan
1 parent 6062e97 commit 8b76273

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

flarestack/core/minimisation.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -919,10 +919,23 @@ def scan_likelihood_1d(
919919
# calculate upper bound for scan
920920
if ("n_s" in param_name) and adjust_bound:
921921
logger.debug("adjusting bound")
922-
best[i] = bound[1]
923-
while g(best) > (min_llh + upper_bound_level**2):
924-
best[i] *= factor
925-
ur = min(bound[1], max(best[i], 0))
922+
if bound[1] is None:
923+
ur = scipy.optimize.fmin_l_bfgs_b(
924+
lambda x: np.abs(
925+
g([*best[:i], x[0], *best[i + 1 :]])
926+
- (min_llh + upper_bound_level**2)
927+
),
928+
x0=best[i] / factor,
929+
bounds=[(best[i], None)],
930+
approx_grad=True,
931+
disp=False,
932+
factr=1e12,
933+
)[0][0]
934+
else:
935+
best[i] = bound[1]
936+
while g(best) > (min_llh + upper_bound_level**2):
937+
best[i] *= factor
938+
ur = min(bound[1], max(best[i], 0))
926939
else:
927940
ur = bound[1]
928941

0 commit comments

Comments
 (0)