Skip to content

Fix m_nonzero_bkg definition to avoid overflows. #231

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

juanma-cano-vila
Copy link
Collaborator

Implemented the proposed solution in issue 230.

As a side effect, it will also softer (but not eliminate) the anomalous high TS values for injections where there was no
events in the background and kde smoothing was used. The reason is that now the bkg energy pdf is effectively capped to numpy.finfo(np.double).resolution (=1e-15).

This still gives much more margin than the cap_ratio option, which effectively imposes much more restrictive values.

This solution just extends the already solution for the actual zero values when no cap_ratio is present.

if self._cap_ratio:
ratio[m_zero_bkg] = self.ratio_fill_value_dict[sig_pdf_key]
else:
np.divide(
ratio,
np.finfo(np.double).resolution,
where=m_zero_bkg,
out=ratio)

@juanma-cano-vila juanma-cano-vila added the bug Something isn't working label Nov 23, 2024
@martwo
Copy link
Collaborator

martwo commented Nov 24, 2024

The fix seems ok. However, I was wondering if the data type (double in this case) should depend on the data type of the PDF values. Because there is the option to compress the data to float32, the limit would also be different in the compressed case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants