-
Notifications
You must be signed in to change notification settings - Fork 0
Use uncertainties in plots and fits #52
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
beea000
backing up what we have so far with bluesky prs
rerpha 8d0a334
Merge remote-tracking branch 'origin/main' into 3_uncertainties_in_pl…
rerpha decb234
add yerr in liveplot wrapper
rerpha 984a1f7
updates fitting for uncertainties
4bc0764
add test for fitting when weights are given
rerpha 768fd0f
unit tests for full coverage
2254809
some ruff fixes
426aa24
ADR draft 1
603d530
update variance addition adr
0904ca0
ruff
043d1a4
Ruff
086c876
restore dae_scan
15b3102
Ruff
02ffb3e
ruff & docs update
a0cafb2
updates docs & adds error bars in manual test
8afeeba
pyright
1ff154d
Merge branch 'main' into 3_uncertainties_in_plots_and_fits
jackbdoughty bba3a6b
Requested changes
b8f9526
Merge branch 'main' into 3_uncertainties_in_plots_and_fits
jackbdoughty ed4a9e0
Merge branch 'main' into 3_uncertainties_in_plots_and_fits
jackbdoughty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Variance addition to counts data | ||
|
|
||
| ## Status | ||
|
|
||
| Current | ||
|
|
||
| ## Context | ||
|
|
||
| For counts data, the uncertainty on counts is typically defined by poisson counting statistics, i.e. the standard deviation on `N` counts is `sqrt(N)`. | ||
|
|
||
| This can be problematic in cases where zero counts have been collected, as the standard deviation will then be zero, which will subsequently lead to "infinite" point weightings in downstream fitting routines for example. | ||
|
|
||
| A number of possible approaches were considered: | ||
|
|
||
| | Option | Description | | ||
| | --- | --- | | ||
| | A | Reject data with zero counts, i.e. explicitly throw an exception if any data with zero counts is seen as part of a scan. | | ||
| | B | Use a standard deviation of `NaN` for points with zero counts. | | ||
| | C | Define the standard deviation of `N` counts as `1` if counts are zero, otherwise `sqrt(N)`. This is one of the approaches available in mantid for example. | | ||
| | D | Define the standard deviation of `N` counts as `sqrt(N+0.5)` unconditionally - on the basis that "half a count" is smaller than the smallest possible actual measurement which can be taken. | | ||
| | E | No special handling, calculate std. dev. as `sqrt(N)`. | | ||
|
|
||
| For clarity, the following table shows the value and associated uncertainty for each option: | ||
|
|
||
| | Counts | Std. Dev. (A) | Std. Dev. (B) | Std. Dev. (C) | Std. Dev. (D) | Std. Dev. (E) | | ||
| | ------- | ------ | ------- | ------- | ------- | --- | | ||
| | 0 | raise exception | NaN | 1 | 0.707 | 0 | | ||
| | 1 | 1 | 1 | 1 | 1.224745 | 1 | | ||
| | 2 | 1.414214 | 1.414214 | 1.414214 | 1.581139 | 1.414214 | | ||
| | 3 | 1.732051 | 1.732051 | 1.732051 | 1.870829 | 1.732051 | | ||
| | 4 | 2 | 2 | 2 | 2.12132 | 2 | | ||
| | 5 | 2.236068 | 2.236068 | 2.236068 | 2.345208 | 2.236068 | | ||
| | 10 | 3.162278 | 3.162278 | 3.162278 | 3.24037 | 3.162278 | | ||
| | 50 | 7.071068 | 7.071068 | 7.071068 | 7.106335 | 7.071068 | | ||
| | 100 | 10 | 10 | 10 | 10.02497 | 10 | | ||
| | 500 | 22.36068 | 22.36068 | 22.36068 | 22.37186 | 22.36068 | | ||
| | 1000 | 31.62278 | 31.62278 | 31.62278 | 31.63068 | 31.62278 | | ||
| | 5000 | 70.71068 | 70.71068 | 70.71068 | 70.71421 | 70.71068 | | ||
| | 10000 | 100 | 100 | 100 | 100.0025 | 100 | | ||
|
|
||
| ## Present | ||
|
|
||
| These approaches were discussed in a regular project update meeting including | ||
| - TW & FA (Experiment controls) | ||
| - CK (Reflectometry) | ||
| - JL (Muons) | ||
| - RD (SANS) | ||
|
|
||
| ## Decision | ||
|
|
||
| The consensus was to go with Option D. | ||
|
|
||
| ## Justification | ||
|
|
||
| - Option A will cause real-life scans to crash in low counts regions. | ||
| - Option B involves `NaN`s, which have many surprising floating-point characteristics and are highly likely to be a source of future bugs. | ||
| - Option D was preferred to option C by scientists present. | ||
| - Option E causes surprising results and/or crashes downstream, for example fitting may consider points with zero uncertainty to have "infinite" weight, therefore effectively disregarding all other data. |
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.