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

Overflow in pdf ratio with KDE smoothing for public data with injection. #230

Open
juanma-cano-vila opened this issue Nov 23, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@juanma-cano-vila
Copy link
Collaborator

When injecting events in an analysis instance with the option kde_smoothing=True, it can happen sometimes that the kde smoothing assigns extremely low values to the bkg pdf, of the order of 1e-200 or lower. This can produce for some injected events to run in an overflow when computing the pdf ratio.

In the current implementation we have

m_nonzero_bkg = bkg_pd > 0
m_zero_bkg = np.invert(m_nonzero_bkg)
if np.any(m_zero_bkg):
ev_idxs = np.where(m_zero_bkg)[0]
self._logger.debug(
f'For {len(ev_idxs)} events the background probability is '
f'zero. The event indices of these events are: {ev_idxs}')
np.divide(
ratio,
bkg_pd,
where=m_nonzero_bkg,
out=ratio)

The m_nonzero_bkg = bkg_pd > 0 is not enough when appliying kde smoothing. I suggest to change it to
m_nonzero_bkg = bkg_pd > np.finfo(np.double).resolution . This will assign this close to 0 values the same treatment as expected with no kde smoothing.

@juanma-cano-vila juanma-cano-vila added the bug Something isn't working label Nov 23, 2024
@juanma-cano-vila juanma-cano-vila self-assigned this Nov 23, 2024
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

No branches or pull requests

1 participant