Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 16 additions & 2 deletions py/dynesty/dynesty.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ def NestedSampler(loglikelihood,
update_func=None,
ncdim=None,
save_history=False,
history_filename=None):
history_filename=None,
proposals=None,
):
"""
Initializes and returns a sampler object for Static Nested Sampling.

Expand Down Expand Up @@ -472,6 +474,10 @@ def prior_transform(u):
just sample uniformly from the prior distribution.
If this is `None` (default), this will default to npdim.

proposals : iterable, optional
A list of proposal functions to use for rwalk evolution. This will be
used as a fixed proposal cycle.

Returns
-------
sampler : sampler from :mod:`~dynesty.nestedsamplers`
Expand Down Expand Up @@ -519,6 +525,7 @@ def prior_transform(u):
kwargs['nonbounded'] = nonbounded
kwargs['periodic'] = periodic
kwargs['reflective'] = reflective
kwargs['proposals'] = proposals

# Keyword arguments controlling the first update.
if first_update is None:
Expand Down Expand Up @@ -663,7 +670,9 @@ def DynamicNestedSampler(loglikelihood,
update_func=None,
ncdim=None,
save_history=False,
history_filename=None):
history_filename=None,
proposals=None,
):
"""
Initializes and returns a sampler object for Dynamic Nested Sampling.

Expand Down Expand Up @@ -868,6 +877,10 @@ def prior_transform(u):
just sample uniformly from the prior distribution.
If this is `None` (default), this will default to npdim.

proposals : iterable, optional
A list of proposal functions to use for rwalk evolution. This will be
used as a fixed proposal cycle.

Returns
-------
sampler : a :class:`dynesty.DynamicSampler` instance
Expand Down Expand Up @@ -918,6 +931,7 @@ def prior_transform(u):
kwargs['nonbounded'] = nonbounded
kwargs['periodic'] = periodic
kwargs['reflective'] = reflective
kwargs['proposals'] = proposals

# Keyword arguments controlling the first update.
if first_update is None:
Expand Down
23 changes: 23 additions & 0 deletions py/dynesty/nestedsamplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .sampler import Sampler
from .bounding import (UnitCube, Ellipsoid, MultiEllipsoid, RadFriends,
SupFriends, rand_choice)
from .proposals import DEFAULT_PROPOSALS, ENSEMBLE_PROPOSALS
from .sampling import (sample_unif, sample_rwalk, sample_slice, sample_rslice,
sample_hslice)
from .utils import unitcheck, get_enlarge_bootstrap
Expand Down Expand Up @@ -137,6 +138,13 @@ def __init__(self,
self.fmove = self.kwargs.get('fmove', 0.9)
self.max_move = self.kwargs.get('max_move', 100)

@property
def proposals(self):
proposals = self.kwargs.get("proposals", None)
if proposals is None:
proposals = DEFAULT_PROPOSALS
return proposals

def propose_unif(self, *args):
pass

Expand Down Expand Up @@ -327,6 +335,9 @@ def propose_live(self, *args):
u = self.live_u[i, :]
ax = np.identity(self.npdim)

if not ENSEMBLE_PROPOSALS.isdisjoint(self.proposals):
self.kwargs["live"] = copy.deepcopy(self.live_u)

return u, ax


Expand Down Expand Up @@ -473,6 +484,9 @@ def propose_live(self, *args):
else:
ax = np.identity(self.ncdim)

if not ENSEMBLE_PROPOSALS.isdisjoint(self.proposals):
self.kwargs["live"] = copy.deepcopy(self.live_u)

return u, ax


Expand Down Expand Up @@ -649,6 +663,9 @@ def propose_live(self, *args):
else:
ax = np.identity(self.npdim)

if not ENSEMBLE_PROPOSALS.isdisjoint(self.proposals):
self.kwargs["live"] = copy.deepcopy(self.live_u)

return u, ax


Expand Down Expand Up @@ -799,6 +816,9 @@ def propose_live(self, *args):
u = self.live_u[i, :]
ax = self.radfriends.axes

if not ENSEMBLE_PROPOSALS.isdisjoint(self.proposals):
self.kwargs["live"] = copy.deepcopy(self.live_u)

return u, ax


Expand Down Expand Up @@ -949,4 +969,7 @@ def propose_live(self, *args):
u = self.live_u[i, :]
ax = self.supfriends.axes

if not ENSEMBLE_PROPOSALS.isdisjoint(self.proposals):
self.kwargs["live"] = copy.deepcopy(self.live_u)

return u, ax
Loading