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

Relative: fix log of zero for default 0 sigma values #1377

Merged
merged 5 commits into from
Apr 19, 2024

Conversation

Doresic
Copy link
Contributor

@Doresic Doresic commented Apr 17, 2024

If an observable has hierarchical noise, but has no measurement at some simulation timepoint for which the model is simulated, then the edata.getObservedData will be nan but the rdata.sigmay for that condition, observable and timepoint will be 0.

This was causing an issue in the direct calculation of the NLLH as we were taking the log(2 * np.pi * sigma_i**2) where sigma_i was rdata.sigmay. This gave RuntimeWarning: divide by zero encountered in log errors.

The fix is simple: mask the sigma_i array with the mask for which the data is not nan. Already available in problem.data_mask.

Was raised in issue #1375

@Doresic Doresic requested a review from dweindl as a code owner April 17, 2024 14:03
@Doresic Doresic self-assigned this Apr 17, 2024
@Doresic Doresic linked an issue Apr 17, 2024 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.72%. Comparing base (3b1a12f) to head (b057c50).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #1377       +/-   ##
============================================
- Coverage    84.41%   53.72%   -30.69%     
============================================
  Files          157      157               
  Lines        12919    12928        +9     
============================================
- Hits         10905     6946     -3959     
- Misses        2014     5982     +3968     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@arrjon arrjon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

Copy link
Member

@dweindl dweindl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thx

@Doresic Doresic merged commit 3edf785 into develop Apr 19, 2024
18 checks passed
@Doresic Doresic deleted the relative_fix_log_of_zero branch April 19, 2024 08:57
This was referenced May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimization with conditions specific for observables fails
4 participants