feat: add reduced statistics and dof to report#240
Open
jamesrafe wants to merge 1 commit intoJuliaAstro:mainfrom
Open
feat: add reduced statistics and dof to report#240jamesrafe wants to merge 1 commit intoJuliaAstro:mainfrom
jamesrafe wants to merge 1 commit intoJuliaAstro:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #240 +/- ##
==========================================
+ Coverage 55.69% 56.56% +0.86%
==========================================
Files 39 39
Lines 2632 2650 +18
==========================================
+ Hits 1466 1499 +33
+ Misses 1166 1151 -15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's Changed
Closes #84 . This PR adds reduced statistics ($\chi_\nu^2$ ) and d.o.f. (degrees of freedom) for the fit results reporting. The reduced statistics and dof will be shown in the fit results report for individual model slices and the total fit, as well as the plot recipe.
The dof function for individual model slices returns ( number of usable data bins ) − ( number of free parameters ). We get the usable data bins count from data_cache[i].objective. In _objective_to_unit, they already applied the data mask, meaning it has excluded bad channels.
We get the free parameters count from free_mask[parameter_bindings[i]]. parameter_bindings[i] returns the indices of the current dataset's parameters. With those indices, we index the global free mask (which contains all parameters, and is 1/true if free, and 0/false if not) with the parameter bindings of that dataset to get an array of free parameters belonging to the current dataset. Then, we just need to count the number of 1 (True) values.
The reduced_statistic function then just takes the statistic of a slice (which we already have) and divide it by the dof of said slice. If dof is zero, it will return Inf or NaN, as per Julia's response.
We do not use the dof function for the total degrees of freedom because of parameter binding. If multiple datasets share a tied parameter, summing up each slice's dof will double-count the tied parameters. Instead, we just use count(free_mask) to get the total free parameters. The number of usable bins can just be summed up though, so we just need to reduce the summed-up objectives by count(free_mask).
Please help in reviewing this, to make sure the math and usage of the variables are correct, and if the format for showing the statistics is good. Thank you very much!
Screenshots
First report and the plot comes from s54405.pha, while second report uses hisum.pha and losum.pha.
Before
After