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

Cstat fix #85

Merged
merged 7 commits into from Feb 16, 2023
Merged

Cstat fix #85

merged 7 commits into from Feb 16, 2023

Conversation

KriSun95
Copy link
Collaborator

@KriSun95 KriSun95 commented Dec 6, 2022

The C-stat likelihood doesn't handle bins of 0 observed counts correctly. In this case, revert to the Poissonian log-likelihood. This means at Data=0, ln(likelihood)=-model.

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2022

Codecov Report

Base: 54.63% // Head: 54.79% // Increases project coverage by +0.15% 🎉

Coverage data is based on head (5e75fbc) compared to base (1a9e105).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #85      +/-   ##
==========================================
+ Coverage   54.63%   54.79%   +0.15%     
==========================================
  Files          19       19              
  Lines        3115     3119       +4     
==========================================
+ Hits         1702     1709       +7     
+ Misses       1413     1410       -3     
Impacted Files Coverage Δ
sunxspex/sunxspex_fitting/likelihoods.py 79.48% <100.00%> (+10.91%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@samaloney samaloney left a comment

Choose a reason for hiding this comment

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

Nice fix, I think it needs a test e.g. calling cstat_loglikelihood function with some data with zeros and making sure it behaves as intended.

Also none of these show up in the doc build which makes it hard to review the changes to the docs would be good to get that sorted maybe not in this PR. I've open a different PR to add the docs #94 you can see a built version here https://sunxspex--94.org.readthedocs.build/en/94/

changelog/85.bugfix.rst Outdated Show resolved Hide resolved
Comment on lines +267 to +268
if len(observed_counts[_zero_data]) > 0:
likelihoods[_zero_data] = -model_counts[_zero_data]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the if statement necessary? _zero_data is a boolean mask so should always work. Unless it a perforce thing but might be faster too?

@samaloney samaloney merged commit 22935b5 into sunpy:master Feb 16, 2023
@KriSun95 KriSun95 deleted the kris-cstat0s branch March 6, 2023 22:26
settwi pushed a commit to settwi/sunkit-spex that referenced this pull request Sep 18, 2023
* Fix bug in cstat calculation with 0 count values
* Added test for c-stat and found/fixed fault in my previous fix while doing so.
* Squeeze away extra array dimensions not needed in cstat.
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.

None yet

3 participants