Constrained Drawing Functions

For the problem of drawing uniformly from the prior, given a minimum likelihood, these are the currently implemented methods:

Rejection sampling

Check the source of this Constrainer for reference, and as a starting point to implementing your own method.

class nested_sampling.samplers.rejection.RejectionConstrainer[source]

Bases: object

Simplest draw function using rejection sampling.

Guaranteed to yield uniform points and not to exclude any maxima. Least efficient method.

Support Vector Machines

class nested_sampling.samplers.svm.SVMConstrainer[source]

Bases: object

This constrainer uses probabilistic Support Vector Machines classifier with Radial basis functions (sklearn.svm.NuSVC) to find a border separating live points and already discarded points.

Then, points are filtered using this classifier. Only points matching the classifier are evaluated.

RadFriends/SupFriends

class nested_sampling.samplers.friends.FriendsConstrainer(rebuild_every=50, radial=True, metric='euclidean', jackknife=False, force_shrink=False, hinter=None, verbose=False)[source]

Bases: object

Rejection sampling pre-filtering method based on neighborhood to live points.

“Distant” means in this implementation that the distance to a cluster member is large. The maximum distance to a cluster is computed by considering each cluster member and its k nearest neighbors in turn, and computing the maximum distance.

Parameters:
  • rebuild_every – After how many iterations should the clustering distance be re-computed?
  • radial – if radial = True, then the normal euclidean distance is used. otherwise, the absolute coordinate difference in each dimension is used.
  • metric – metric to use. Use ‘chebyshev’ for SupFriends, in which case then the supremum norm is used. Use ‘euclidean’ for RadFriends, via the euclidean norm.
  • jackknife – if True, instead of leaving out a group of live points in the distance estimate, only one is left out in turn (jackknife resampling instead of bootstrap resampling).
  • force_shrink – if True, the distance can only decrease between sampling steps.
are_inside_rect(u)[source]

Check if the new points are near or inside one of our clusters

cluster(u, ndim, keepRadius=False)[source]
is_inside(u)[source]

Check if this new point is near or inside one of our clusters

Markov Chain Monte Carlo

class nested_sampling.samplers.mcmc.BaseProposal(adapt=False, scale=1.0)[source]

Bases: object

Base class for proposal function.

Parameters:
  • scale – Scale of proposal
  • adapt – Adaptation rule to use for scale, when new_chain is called.

If adapt is False, no adaptation is done. If adapt is ‘Sivia’, the rule of Sivia & Skilling (2006) is used. If adapt is something else, a crude thresholding adaptation is used to gain ~50% acceptance.

class nested_sampling.samplers.mcmc.GaussProposal(adapt=False, scale=1.0)[source]

Bases: nested_sampling.samplers.mcmc.BaseProposal

Symmetric gaussian proposal.

@see BaseProposal

class nested_sampling.samplers.mcmc.MCMCConstrainer(nsteps=200, proposer=MultiScaleProposal(loc=-4.5, scale=1.5, adapt=False), nmaxsteps=10000)[source]

Bases: object

Markov chain Monte Carlo proposals using the Metropolis update: Do a number of steps, while adhering to boundary.

class nested_sampling.samplers.mcmc.MultiScaleProposal(loc=-4.5, scale=1.5, adapt=False)[source]

Bases: nested_sampling.samplers.mcmc.BaseProposal

Proposal over multiple scales, inspired by DNest. Uses the formula

\(x + n * 10^{l - s * u}\)

where l is the location, s is the scale and u is a uniform variate, and n is a normal variate.

@see MultiScaleProposal

RadFriends/Galilean and MCMC hybrid methods

class nested_sampling.samplers.galilean.GalileanRadFriendsConstrainer(nlive_points, ndim, velocity_scale=0.5, nsteps=20, plot=False)[source]

Bases: nested_sampling.samplers.galilean.HybridRadFriendsConstrainer

Galilean Nested Sampling is a special case of Nested Sampling using Hamiltonian Monte Carlo. Here we use RadFriends to determine the reflection surfaces.

are_inside_rect(u)

Check if the new points are near or inside one of our clusters

is_inside(u)

Check if this new point is near or inside one of our clusters

reflect(u, v)[source]

Find reflection surface for line u + t*v, t>0

class nested_sampling.samplers.galilean.HybridRadFriendsConstrainer(nsteps=20, plot=False)[source]

Bases: object

Base class to use RadFriends (with enforced shrinking, JackKnife resampling) in combination with local step sampling methods.

are_inside_rect(u)[source]

Check if the new points are near or inside one of our clusters

is_inside(u)[source]

Check if this new point is near or inside one of our clusters

class nested_sampling.samplers.galilean.MCMCRadFriendsConstrainer(proposal_scale=3, nsteps=20, plot=False)[source]

Bases: nested_sampling.samplers.galilean.HybridRadFriendsConstrainer

Markov Chain Monte Carlo sampling

Here we use RadFriends to restrict the proposal distribution.

are_inside_rect(u)

Check if the new points are near or inside one of our clusters

is_inside(u)

Check if this new point is near or inside one of our clusters