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

Gsl integration bugfix #300

Merged
merged 5 commits into from
Apr 25, 2023
Merged

Gsl integration bugfix #300

merged 5 commits into from
Apr 25, 2023

Conversation

thjsal
Copy link
Contributor

@thjsal thjsal commented Mar 30, 2023

Numerical problems in likelihood computation were fixed for cases with zero counts, preventing also the code from being incorrectly optimized on Intel CPUs when using Intel compilers (producing incorrect GSL integration results and likelihoods). For the tested cases, the effect of these fixes seems non-detectable for the results in the systems where the optimization was already working correctly.

Treatment of the special cases in the likelihood computation in xpsi/likelihoods/default_background_marginalisation.pyx was changed so that taking the logarithm of zero is not allowed anymore. Previously, that could happen if the modelled counts were zero, but the observed counts were not.

In addition, in case they both are zero, we now add 0 (i.e., log(1)) to the log-likelihood, instead of 1 added before.

thjsal and others added 4 commits March 29, 2023 19:07
Added comments and missing docstrings to the likelihood calculation and background marignalisation.
@thjsal thjsal added bug Something isn't working bugfix and removed bug Something isn't working labels Mar 30, 2023
@thjsal thjsal requested review from yveskini and Basdorsman April 11, 2023 21:27
@thjsal
Copy link
Contributor Author

thjsal commented Apr 14, 2023

To explain a bit more about the additional change in the code:
The reason why I think adding 0 (instead of 1) is correct, is that it seems reasonable that the probability for 0 observed counts is 1, and the probability for any other number of observed counts is 0, if the model predicts 0 zero counts. And since we are summing here log probabilities, log(1)=0 should be added and not 1. Does this make sense for others too?

@thjsal thjsal merged commit aaae64e into main Apr 25, 2023
@thjsal thjsal deleted the gsl-integration-bugfix branch June 9, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants