Skip to content

Commit

Permalink
changed defaults
Browse files Browse the repository at this point in the history
This commit resolves #87. The default options for a host of parameters has
been changed to enable more stable behavior for the average user. These are:
- `nlive` has been changed to `500` everywhere to enable better default
performance in moderate dimensions. This includes in `nlive_init` and
`nlive_batch` in `dynamicsampler`.
- `update_interval` has been increased to `0.8`.
- The `dlogz` formula for the static `sampler` has been modified to
`1e-3 * (nlive - 1) + 0.01` so that it is a better compromise between
evidence and posterior estimation. This gives `~0.5` when `nlive=500`,
similar to the previous `nestle` value, which I think is more appropriate.

I might revisit the sampling options in the near future to further accomodate
users who want to apply it right away to arbitrary-dimensional problems.
  • Loading branch information
joshspeagle committed Mar 17, 2018
1 parent 2149844 commit 343849f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dynesty/__init__.py
Expand Up @@ -10,4 +10,4 @@
from . import utils


__version__ = "0.9.1d"
__version__ = "0.9.1e"
20 changes: 10 additions & 10 deletions dynesty/dynamicsampler.py
Expand Up @@ -585,7 +585,7 @@ def results(self):

return Results(results)

def sample_initial(self, nlive=100, update_interval=None,
def sample_initial(self, nlive=500, update_interval=None,
first_update=None, maxiter=None, maxcall=None,
logl_max=np.inf, dlogz=0.01, live_points=None):
"""
Expand All @@ -598,7 +598,7 @@ def sample_initial(self, nlive=100, update_interval=None,
----------
nlive : int, optional
The number of live points to use for the baseline nested
sampling run. Default is `100`.
sampling run. Default is `500`.
update_interval : int or float, optional
If an integer is passed, only update the bounding distribution
Expand Down Expand Up @@ -873,7 +873,7 @@ def sample_initial(self, nlive=100, update_interval=None,
self.saved_batch_nlive.append(self.nlive_init) # initial nlive
self.saved_batch_bounds.append((-np.inf, np.inf)) # initial bounds

def sample_batch(self, nlive_new=100, update_interval=None,
def sample_batch(self, nlive_new=500, update_interval=None,
logl_bounds=None, maxiter=None, maxcall=None,
save_bounds=True):
"""
Expand All @@ -885,7 +885,7 @@ def sample_batch(self, nlive_new=100, update_interval=None,
Parameters
----------
nlive_new : int
Number of new live points to be added. Default is `100`.
Number of new live points to be added. Default is `500`.
update_interval : int or float, optional
If an integer is passed, only update the bounding distribution
Expand Down Expand Up @@ -1370,9 +1370,9 @@ def combine_runs(self):
self.saved_batch_nlive.append(max(new_n))
self.saved_batch_bounds.append((llmin, llmax))

def run_nested(self, nlive_init=100, maxiter_init=None,
def run_nested(self, nlive_init=500, maxiter_init=None,
maxcall_init=None, dlogz_init=0.01, logl_max_init=np.inf,
nlive_batch=100, wt_function=None, wt_kwargs=None,
nlive_batch=500, wt_function=None, wt_kwargs=None,
maxiter_batch=None, maxcall_batch=None,
maxiter=None, maxcall=None, maxbatch=None,
stop_function=None, stop_kwargs=None, use_stop=True,
Expand All @@ -1388,7 +1388,7 @@ def run_nested(self, nlive_init=100, maxiter_init=None,
----------
nlive_init : int, optional
The number of live points used during the initial ("baseline")
nested sampling run. Default is `100`.
nested sampling run. Default is `500`.
maxiter_init : int, optional
Maximum number of iterations for the initial baseline nested
Expand Down Expand Up @@ -1417,7 +1417,7 @@ def run_nested(self, nlive_init=100, maxiter_init=None,
nlive_batch : int, optional
The number of live points used when adding additional samples
from a nested sampling run within each batch. Default is `100`.
from a nested sampling run within each batch. Default is `500`.
wt_function : func, optional
A cost function that takes a :class:`Results` instance
Expand Down Expand Up @@ -1594,7 +1594,7 @@ def run_nested(self, nlive_init=100, maxiter_init=None,
if print_progress:
sys.stderr.write("\n")

def add_batch(self, nlive=100, wt_function=None, wt_kwargs=None,
def add_batch(self, nlive=500, wt_function=None, wt_kwargs=None,
maxiter=None, maxcall=None, save_bounds=True,
print_progress=True, print_func=None, stop_val=None):
"""
Expand All @@ -1606,7 +1606,7 @@ def add_batch(self, nlive=100, wt_function=None, wt_kwargs=None,
----------
nlive : int, optional
The number of live points used when adding additional samples
in the batch. Default is `100`.
in the batch. Default is `500`.
wt_function : func, optional
A cost function that takes a `Results` instance
Expand Down
8 changes: 4 additions & 4 deletions dynesty/dynesty.py
Expand Up @@ -37,9 +37,9 @@
SQRTEPS = math.sqrt(float(np.finfo(np.float64).eps))


def NestedSampler(loglikelihood, prior_transform, ndim, nlive=250,
def NestedSampler(loglikelihood, prior_transform, ndim, nlive=500,
bound='multi', sample='unif',
update_interval=0.6, first_update=None,
update_interval=0.8, first_update=None,
npdim=None, rstate=None, queue_size=None, pool=None,
use_pool=None, live_points=None,
logl_args=None, logl_kwargs=None,
Expand Down Expand Up @@ -314,8 +314,8 @@ def prior_transform(u):

def DynamicNestedSampler(loglikelihood, prior_transform, ndim,
bound='multi', sample='unif',
update_interval=0.6, first_update=None,
npdim=None, rstate=None, queue_size=1, pool=None,
update_interval=0.8, first_update=None,
npdim=None, rstate=None, queue_size=None, pool=None,
use_pool=None, logl_args=None, logl_kwargs=None,
ptform_args=None, ptform_kwargs=None,
enlarge=None, bootstrap=None,
Expand Down
4 changes: 2 additions & 2 deletions dynesty/sampler.py
Expand Up @@ -785,7 +785,7 @@ def run_nested(self, maxiter=None, maxcall=None, dlogz=None,
`ln(z + z_est) - ln(z) < dlogz`, where `z` is the current
evidence from all saved samples and `z_est` is the estimated
contribution from the remaining volume. If `add_live` is `True`,
the default is `0.005 * (nlive + 1)`. Otherwise, the
the default is `1e-3 * (nlive - 1) + 0.01`. Otherwise, the
default is `0.01`.
logl_max : float, optional
Expand Down Expand Up @@ -817,7 +817,7 @@ def run_nested(self, maxiter=None, maxcall=None, dlogz=None,
# Define our stopping criteria.
if dlogz is None:
if add_live:
dlogz = 0.005 * (self.nlive + 1.)
dlogz = 1e-3 * (self.nlive - 1.) + 0.01
else:
dlogz = 0.01

Expand Down

0 comments on commit 343849f

Please sign in to comment.