-
Notifications
You must be signed in to change notification settings - Fork 58
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
Sampler Additions and PSR Jump Proposals #127
Conversation
I should point out that this PR does touch on some of the topics addressed in Issue #19, started by @paulthebaker. There is still some work to be done regarding efficient setup of these various proposals though. |
Codecov Report
@@ Coverage Diff @@
## master #127 +/- ##
==========================================
- Coverage 27.98% 27.69% -0.29%
==========================================
Files 19 19
Lines 3277 3416 +139
==========================================
+ Hits 917 946 +29
- Misses 2360 2470 +110
Continue to review full report at Codecov.
|
It makes sense that pulsar prior draw is very unlikely to be accepted after the first couple of steps. If you attempt to move many parameters at once, the probability that at least one will end up in a bad spot is pretty high. The code works, but I would guess that it's almost never worth including that particular draw. |
@paulthebaker The acceptance rate for that draw is pretty reasonable (18%) in the advanced noise modeling full PTA run. I think it might be because many of the pulsars only have power law red noise so the draw is pulling a sample of red noise parameters only. It is lower than the red noise prior draw, but that makes sense since when it was pulling from a normal pulsar it would be jumping in 2 parameters, and when it was jumping in an advanced noise pulsar it would not be accepted very often for the reasons you give above. |
if os.path.exists(outdir+'/cov.npy'): | ||
cov = np.load(outdir+'/cov.npy') | ||
else: | ||
cov = np.diag(np.ones(ndim) * 1.0**2)## used to be 0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic modification that we've needed for a while. Thanks Jeff.
enterprise_extensions/sampler.py
Outdated
@@ -863,7 +965,7 @@ def setup_sampler(pta, outdir='chains', resume=False, empirical_distr=None): | |||
sampler.addProposalToCycle(jp.draw_from_ephem_prior, 10) | |||
|
|||
# GWB uniform distribution draw | |||
if 'gw_log10_A' in pta.param_names: | |||
if 'gw_log10_A' in pta.param_names or 'gw_crn_log10_A' in pta.param_names: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be even more general, @Hazboun6? This will work if the ORF is None
such that the process is a crn
, but in model_general
the processes get named for their ORF behavior: https://github.com/nanograv/enterprise_extensions/blob/master/enterprise_extensions/models.py#L788. So a H&D process would have gw_hd_log10_A
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You make a good point @stevertaylor . I've changed the jump proposal to cycle through any signals with "gw" and "log10_A" in the parameter names and now sampler.setup_sampler
and HyperModel.setup_ampler
do searches for the same string pieces in order to add the jump proposal.
See lines 369 and 968 of sampler.py
and line 256 of hypermodel.py
.
This PR combines a number of small changes to the samplers that allow them to be tweaked by users if they wish, as well as adding in 3 new jump proposals and a new function for parameter groupings. Many of these additions were developed for full PTA advanced noise model sampling where pulsars now have upwards of 10+ new parameters pertaining to their noise models, but some of these methods should be more widely useful. The user interface has not changed at all. The changes either need to be implemented by the user (e.g. making pulsar noise parameter groups) or will happen through the course of the usual interface (e.g. chromatic GP prior draw jump proposals will be added if
chrom_gp
is in the list of signal names for aHyperModel
run.)The small tweaks include:
HyperModel
and the usual sampler haveself.jp=jp
added to the code so that theJumpProposal
class is available to the user. This allows one to add more jump proposals to the proposal scheme. These can be new proposals or more of the same ones. For instance we have found that weighting the empirical distributions more strongly helps with sampling. Since the sampler setup weights all proposals the same, this allows a user to put more of their preferred jump proposals in the cycle.HyperModel
and the usual sampler look for acov.npy
file in theoutdir
before making a generic one. This helps with sampling of resumed chains.SCAM
,AM
andDE
jumps. If no list of groups is set manually thesampler.get_parameter_groups()
method is used. This option was already available inHyperModel.setup_sampler
and so homogenizes the code interface.sampler.get_psr_groups()
method has been added which allows users to retrieve lists of parameter indices that combine all parameters with a given pulsar's name in the parameter name. This allows for covariance jumps in all of a pulsar's parameters at one.Below is an example of how one might use some of this new functionality:
New Jump Proposals:
chrom_gp
type signals.Neither of these last two jump proposals are currently added automatically by the code. They would replicate already existing jump proposals in a "normal" analysis with only achromatic red noise models for the individual pulsars and some common signal. However I've currently left it to the user to add them by hand.
I have not added tests for these proposals, as there are no tests yet for any of our jump proposals. We should discuss the best way to add in tests for all of our jump proposals.