sherpa
sherpa copied to clipboard
WIP rework PR #617
#Note This PR is basically PR #617 (but without the test script for now) so @anetasie can start testing
The requirements for this PR can be found at: https://cxcjira.cfa.harvard.edu/confluence/display/SH/Update+pyBlocxs
Description
Aside from the following minor change, restricting the fit-statistic to only be Cash
to allow the fit statistic to be one of the following Cash, CStat
or WStat
to be consistent with the get_draws
. The only work done for this PR was to convert the prototype which can be found at:
https://github.com/astrostat/pyblocxs
to run on python 3.
Note
I need the following from SDS: 1) What should the function be called, the prototype calls it 'mh_sampling_newdata'. 2) I need the doc for the new functionality. 3) The function dmvt is defined in the currrent version of sherpa (see file sim/mh.py) and in the prototype but they have different functionality. Should dmvt in the sim/mh.py file be replaced?
(sherpa3) [dtn@devel12 pyblocxs]$ grep dmvt /export/sherpa/sherpa/sim/mh.py | grep def
def dmvt(x, mu, sigma, dof, log=True, norm=False):
def dmvt(self, x, log=True, norm=False):
versus sherpa3) [dtn@devel12 pyblocxs]$ grep dmvt mhtest.py | grep def
def dmvt(self, x, mu, sigma, df, log = True, norm = False):
4) The constant con_prob_prev
is currently hard-wired to 100 in the included
prototype mhtest.py, should it be an option for the new function.
(sherpa3) [dtn@devel12 sherpa]$ grep con_prob_prev /export/sherpa/sherpa/sim/mhtest.py
con_prob_prev = 100
alpha = np.exp(stat_proposal - stat_prev + con_prob_prev - \
alpha = np.exp(stat_proposal - stat_prev + con_prob_prev - \
con_prob_prev = con_prob_proposal
Caveat
user may encounter the following errors:
raise RuntimeError("Error: con_var is not positive semi-definite")
RuntimeError: Error: con_var is not positive semi-definite
or
raise ValueError("Error: sigma is not symmetric")
ValueError: Error: sigma is not symmetric
which I have not attempted to fix
@dtnguyen2 and @DougBurke The code that have been already placed in Sherpa to deal with the calibration uncertainties in included in this directory: https://github.com/sherpa/sherpa/tree/main/sherpa/astro/sim
These two files fullbayes.py
and pragbayes.py
are used if set_sampler
is set to pragbayes
or fullbayes
. It is not clear if there is a difference between these functions and the new code. The ARF file I/O is set as an option opt=simarf
for these samplers. It is not clear if that's the best solution, but current setup works. Here is part of my notebook:
https://github.com/anetasie/SherpaNotebooks/blob/master/Bayes.uncertainty-Test.ipynb
The relevant part is here:
There are a few things that needs to be done: (1) check the difference between the code in this PR and the existing pragbayes and fullbayes functions. Do we need the new function or can we fold in the functionality in this PR into the existing code? (2) understand why there is a failure with changes to the iteration numbers