Skip to content

Commit

Permalink
Save dtype of valid_fit as bool (#123)
Browse files Browse the repository at this point in the history
* Save dtype of `valid_fit` as bool

* Fix typo
  • Loading branch information
dachengx authored Dec 14, 2023
1 parent 6348dfc commit 82edcd7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion alea/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@ def _get_parameter_list(self):
"""Get parameter list and result list from statistical model."""
parameter_list = sorted(self.model.get_parameter_list())
# add likelihood, lower limit, upper limit, and the migrad valid fit bool
result_names = parameter_list + ["ll", "dl", "ul", "valid_fit"]
result_names = parameter_list + ["ll", "dl", "ul"]
result_dtype = [(n, float) for n in result_names]
result_names += ["valid_fit"]
result_dtype += [("valid_fit", bool)]
return result_names, result_dtype

def _get_hypotheses(self):
Expand Down
12 changes: 8 additions & 4 deletions alea/submitters/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,16 @@ def submit(
lltrue = results[true_name]["ll"]
llrs = 2.0 * (llfree - lltrue)
if llrs.min() < 0.0:
mean_valid = (
results[free_name]["valid_fit"] & results[true_name]["valid_fit"]
).mean()
self.logging.warning(
f"The lowest log likelihood ratio is negative {llrs.min():.2e}, "
f"The lowest log likelihood ratio is negative {llrs.min():.02e}, "
f"total fraction of negative log likelihood ratio is "
f"{(llrs < 0.0).sum() / len(llrs):.2f}, "
"the median if negative log likelihood ratios "
f"is {np.median(llrs[llrs < 0.0]):.2e}, "
f"{(llrs < 0.0).sum() / len(llrs):.02f}, "
f"total fraction of invalid fit is {1 - mean_valid:.02f}, "
f"the median of negative log likelihood ratios "
f"is {np.median(llrs[llrs < 0.0]):.02e}, "
f"there might be a problem in your fitting."
)
if len(llrs) < 1000:
Expand Down

0 comments on commit 82edcd7

Please sign in to comment.