bilby.core.sampler.dynesty3_utils.AcceptanceTrackingRWalk
- class bilby.core.sampler.dynesty3_utils.AcceptanceTrackingRWalk(**kwargs)[source]
Bases:
EnsembleWalkSampler
This is a modified version of dynesty.sampling.sample_rwalk that runs the MCMC random walk for a user-specified number of a crude approximation to the autocorrelation time.
This is the proposal method used by default for
Bilby<2
and corresponds to specifyingsample="rwalk"
- __init__(**kwargs)[source]
Initialize the internal sampler.
Importantely this sets up the sampler_kwargs that is being passed to each .sample() call
- Parameters:
- kwargsdict
A dictionary of additional method-specific parameters. This common keywords:
- nonboundedarray
Array of boolean values indicating which dimensions are non-bounded.
- periodicarray
Array of boolean values indicating which dimensions are periodic.
- reflectivearray
Array of boolean values indicating which dimensions are reflective.
- ndim: int
Number of dimensions.
- __call__(*args, **kwargs)
Call self as a function.
Methods
__init__
(**kwargs)Initialize the internal sampler.
estimate_nmcmc
(accept_ratio[, safety, tau, ...])Estimate autocorrelation length of chain using acceptance fraction
prepare_sampler
([loglstar, points, axes, ...])Prepare the list of arguments for sampling.
sample
(args)Return a new live point proposed by random walking away from an existing live point.
tune
(tuning_info[, update])Update the proposal parameters based on the number of accepted steps and MCMC chain length.
Attributes
citations
old_act
How often to force updating the bounds The value is in units of ncall per nlive.
- static estimate_nmcmc(accept_ratio, safety=5, tau=None, maxmcmc=5000, old_act=None)[source]
Estimate autocorrelation length of chain using acceptance fraction
Using ACL = (2/acc) - 1 multiplied by a safety margin. Code adapted from:
- Parameters:
- accept_ratio: float [0, 1]
Ratio of the number of accepted points to the total number of points
- old_act: int
The ACT of the last iteration
- maxmcmc: int
The maximum length of the MCMC chain to use
- safety: int
A safety factor applied in the calculation
- tau: int (optional)
The ACT, if given, otherwise estimated.
Notes
This method does not compute a reliable estimate of the autocorrelation length for our proposal distributions.
- prepare_sampler(loglstar=None, points=None, axes=None, seeds=None, prior_transform=None, loglikelihood=None, nested_sampler=None)[source]
Prepare the list of arguments for sampling.
- Parameters:
- loglstarfloat
Ln(likelihood) bound.
- points~numpy.ndarray with shape (n, ndim)
Initial sample points.
- axes~numpy.ndarray with shape (ndim, ndim)
Axes used to propose new points.
- seeds~numpy.ndarray with shape (n,)
Random number generator seeds.
- prior_transformfunction
Function transforming a sample from the a unit cube to the parameter space of interest according to the prior.
- loglikelihoodfunction
Function returning ln(likelihood) given parameters as a 1-d ~numpy array of length ndim.
- nested_sampler~dynesty.samplers.Sampler
The nested sampler object used to sample.
- Returns:
- arglist:
List of SamplerArgument objects containing the parameters needed for sampling.
- static sample(args)[source]
Return a new live point proposed by random walking away from an existing live point.
- Parameters:
- u~numpy.ndarray with shape (ndim,)
Position of the initial sample. This is a copy of an existing live point.
- loglstarfloat
Ln(likelihood) bound.
- axes~numpy.ndarray with shape (ndim, ndim)
Axes used to propose new points. For random walks new positions are proposed using the
Ellipsoid
whose shape is defined by axes.- scalefloat
Value used to scale the provided axes.
- prior_transformfunction
Function transforming a sample from the a unit cube to the parameter space of interest according to the prior.
- loglikelihoodfunction
Function returning ln(likelihood) given parameters as a 1-d ~numpy array of length ndim.
- kwargsdict
A dictionary of additional method-specific parameters.
- Returns:
- u~numpy.ndarray with shape (ndim,)
Position of the final proposed point within the unit cube.
- v~numpy.ndarray with shape (ndim,)
Position of the final proposed point in the target parameter space.
- loglfloat
Ln(likelihood) of the final proposed point.
- ncint
Number of function calls used to generate the sample.
- sampling_infodict
Collection of ancillary quantities used to tune
scale
.
- tune(tuning_info, update=True)[source]
Update the proposal parameters based on the number of accepted steps and MCMC chain length.
The
walks
parameter to asymptotically approach the desired number of accepted steps.
- property update_bound_interval_ratio
How often to force updating the bounds The value is in units of ncall per nlive. I.e. the value of 10 means for N live points, the bound will be updated every 10 * N calls