Skip to content

Commit

Permalink
Merge pull request #119 from johannesulf/nautilus
Browse files Browse the repository at this point in the history
Update nautilus integration to 1.0
  • Loading branch information
joezuntz authored May 29, 2024
2 parents ed82fb2 + dbf6648 commit 5f92934
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions cosmosis/samplers/nautilus/nautilus_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def config(self):
self.f_live = self.read_ini("f_live", float, 0.01)
self.n_shell = self.read_ini("n_shell", int, self.n_batch)
self.n_eff = self.read_ini("n_eff", float, 10000.0)
self.n_like_max = self.read_ini("n_like_max", int, -1)
if self.n_like_max < 0:
self.n_like_max = np.inf
self.discard_exploration = self.read_ini(
"discard_exploration", bool, False)
self.verbose = self.read_ini("verbose", bool, False)
Expand Down Expand Up @@ -92,6 +95,7 @@ def execute(self):
sampler.run(f_live=self.f_live,
n_shell=self.n_shell,
n_eff=self.n_eff,
n_like_max=self.n_like_max,
discard_exploration=self.discard_exploration,
verbose=self.verbose)

Expand All @@ -102,11 +106,11 @@ def execute(self):
logp = logl + prior
self.output.parameters(sample, extra, logwt, prior, logp)

self.output.final(
"efficiency", sampler.effective_sample_size() / sampler.n_like)
self.output.final("neff", sampler.effective_sample_size())
self.output.final("efficiency", sampler.n_eff / sampler.n_like)
self.output.final("neff", sampler.n_eff)
self.output.final("nsample", len(sampler.posterior()[0]))
self.output.final("log_z", sampler.evidence())
self.output.final("log_z", sampler.log_z)
self.output.final("log_z_error", 1.0 / np.sqrt(sampler.n_eff))
self.converged = True

def is_converged(self):
Expand Down
2 changes: 1 addition & 1 deletion cosmosis/samplers/nautilus/sampler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ params:
n_networks: (integer; default=4) number of neural networks in each network ensemble
n_batch: (integer; default=100) number of likelihood evaluations that are performed at each step
seed: (integer, default=-1) random seed, no fixed seed is used if negative
random_state: (int; default=-1) random seed, negative values give a random random seed
filepath: (string; default='None') file used for checkpointing, must have .hdf5 ending
resume: (bool; default=False) if True, resume from previous run stored in `filepath`
f_live: (float; default=0.01) live set evidence fraction when exploration phase terminates
n_shell: (int; default=n_batch) minimum number of points in each shell
n_eff: (float; default=10000.0) minimum effective sample size
n_like_max: (int; default=-1) maximum number of likelihood calls, negative values are interpreted as infinity
discard_exploration: (bool; default=False) whether to discard points drawn in the exploration phase
verbose: (bool; default=False) If true, print information about sampler progress
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ mpi4py
dulwich
urllib3
scikit-learn
nautilus-sampler == 0.6.*
nautilus-sampler >= 1.0.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def run(self):
"emcee",
"dynesty",
"zeus-mcmc",
"nautilus-sampler==0.6.*",
"nautilus-sampler>=1.0.1",
"dulwich",
"scikit-learn",
"future",
Expand Down

0 comments on commit 5f92934

Please sign in to comment.