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

Oslo method errors #187

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
da6739e
Added a Fermi-Gas like probability distribution
vetlewi Aug 3, 2021
5c1aa9b
Added ErrorFinder class
vetlewi Aug 3, 2021
97ca023
Changed filename for EnsembleNormalizer
vetlewi Aug 3, 2021
6efe711
Fixed bugs and make sure the dist test works
vetlewi Aug 3, 2021
cf266fa
Debug etc
vetlewi Aug 3, 2021
2d4c162
An updated, now fully working version of the error_finder class
vetlewi Aug 11, 2021
9682048
Added pyMC3 as dependency
vetlewi Aug 11, 2021
8ae8a10
Updated release notes
vetlewi Aug 11, 2021
88c7ac7
Initial version of the notebook
vetlewi Aug 11, 2021
65cae01
Added a call wrapper
vetlewi Aug 12, 2021
0e10713
Added an indices method similar to that of the Matrix class
vetlewi Aug 12, 2021
06796a6
Added uncertainty estimation after extraction
vetlewi Aug 12, 2021
14d79b0
Added note about the indices method
vetlewi Aug 12, 2021
13d896f
Overwrite file output to ensure errors are stored
vetlewi Aug 12, 2021
54ace62
Bugfix
vetlewi Aug 13, 2021
4331b52
Updates of the notebook
vetlewi Sep 27, 2021
92b3097
Fixing some style issues
vetlewi Sep 27, 2021
f50b513
Update release_note.md
vetlewi Sep 30, 2021
e5de25d
Moved `all_equal` function to end of file
vetlewi Sep 30, 2021
c958eb6
Update ompy/error_finder.py
vetlewi Sep 30, 2021
ba988f2
Minor style fixes
vetlewi Sep 30, 2021
8d6c577
Better error message
vetlewi Sep 30, 2021
785c674
Better comments
vetlewi Sep 30, 2021
4fb4766
Added note about the new notebook
vetlewi Sep 30, 2021
df97416
Prior params can be modified
vetlewi Oct 13, 2021
00e62f1
Added todo
vetlewi Oct 13, 2021
48cb4bb
Added option to suppress warnings
vetlewi Oct 22, 2021
dee03d7
Changed formula
vetlewi Oct 27, 2021
3a72c2f
Added plot example to docstring
vetlewi Oct 27, 2021
760a979
Removed the linear version
vetlewi Oct 28, 2021
621c95c
Refactoring of error_finder
vetlewi Oct 29, 2021
8ffc7e7
Ensure nan is removed
vetlewi Jan 5, 2022
19c79b7
Similar to previous commit, but with some additional fixes
vetlewi Jan 5, 2022
ab00bd8
Added kwargs
vetlewi Jan 5, 2022
419e1a0
Added option to get the trace from the inference
vetlewi Jan 5, 2022
0d87d8f
Merge branch 'nan-remove-normalizers' into oslo-method-errors
vetlewi Jan 5, 2022
0e61dff
Some changes... Only here though...
vetlewi Jul 25, 2022
394e29d
Updated to work with pymc version 5
vetlewi Jan 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prior params can be modified
The prior parameters for σ_ρ and σ_f (`lam` & `mu`) can now be modified by the user.
vetlewi committed Oct 28, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit df974169c65d9da8ee47ac484460b1c972f6e76c
22 changes: 17 additions & 5 deletions ompy/error_finder.py
Original file line number Diff line number Diff line change
@@ -28,8 +28,12 @@ class ErrorFinder:
testvals (dict): A dictionary with testvalues to feed to pymc3 when
declaring the prior distributions. This can probably be left to
the default, but could be changed if needed.
trace: The trace of the inference data. None if the class hasn't
ran.
TODO:
- The linear model is currently not very well optimized. Usually fails.
- Trace should always be saved. Calculations can take hours!
- Refactor the linear model (maybe remove?)
"""

LOG = logging.getLogger(__name__) # overwrite parent variable
@@ -55,6 +59,9 @@ def __init__(self, algorithm: Optional[str] = 'log',
self.seed = seed
self.testvals = {'σ_D': 0.25, 'σ_F': 0.25, 'σ_α': 0.05,
'σ_A': 0.25, 'σ_B': 0.25, 'A': 1.0, 'B': 1.0}
self.prior_parameters = {'σ_ρ': {'lam': 10., 'mu': 1.},
'σ_f': {'lam': 10., 'mu': 1.}}
self.trace = None

def __call__(self, *args) -> Union[Tuple[Vector, Vector], Any]:
""" Wrapper for evaluate """
@@ -135,20 +142,25 @@ def logarithm(self, E_nld: ndarray, E_gsf: ndarray,
F = pm.Normal("F", mu=0., sigma=σ_F, shape=[N, N-1])[:, coef_gsf]
α = pm.Normal("α", mu=0., sigma=σ_α, shape=[N, N-1])

σ_ρ = FermiDirac("σ_ρ", lam=10., mu=1., shape=M_nld)[vals_nld]
σ_f = FermiDirac("σ_f", lam=10., mu=1., shape=M_gsf)[vals_gsf]
σ_ρ = FermiDirac("σ_ρ", lam=self.prior_parameters['σ_ρ']['lam'],
mu=self.prior_parameters['σ_ρ']['mu'],
shape=M_nld)[vals_nld]

σ_f = FermiDirac("σ_f", lam=self.prior_parameters['σ_f']['lam'],
mu=self.prior_parameters['σ_f']['mu'],
shape=M_gsf)[vals_gsf]

μ_ρ = D + α[:, coef_nld] * E_nld[vals_nld]
μ_f = F + α[:, coef_gsf] * E_gsf[vals_gsf]

ρ_obs = pm.Normal("ρ_obs", mu=μ_ρ, sigma=σ_ρ,
ρ_obs = pm.Normal("ρ_obs", mu=μ_ρ, sigma=np.sqrt(2)*σ_ρ,
observed=np.log(nld_obs))
f_obs = pm.Normal("f_obs", mu=μ_f, sigma=σ_f,
f_obs = pm.Normal("f_obs", mu=μ_f, sigma=np.sqrt(2)*σ_f,
observed=np.log(gsf_obs))

# Perform the sampling
trace = pm.sample(random_seed=self.seed, **self.options)

self.trace = trace
self.display_results(trace)

mid = np.median if median else np.mean