Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save dtype of valid_fit as bool #123

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading