Return more than one rwalk sample on each iteration
Currently, each parallel process returns a single sample point from rwalk. By returning X fair draws from the rwalk mcmc, this should be equivalent to increasing the number of parallel processes by a factor of around X.
I've started by looking in analysis.py
. On the surface, it seems easy enough. If we wanted to return, say, half of the samples we'd just do (line 790):
# If the act is finite, pick randomly from within the chain
if np.isfinite(act) and int(.5 * nact * act) < len(u_list):
n_draws = max(1,int(len(u_list)/2.)) # take up to half of the samples
idx = np.random.randint(int(.5 * nact * act), len(u_list), size=n_draws)
u = list(np.array(u_list)[idx])
v = list(np.array(v_list)[idx])
logl = list(np.array(logl_list)[idx])
However, this fails down the line
Traceback (most recent call last):
File "/fred/oz170/rsmith/anaconda3/envs/pbilby_exp/bin/parallel_bilby_analysis", line 33, in <module>
sys.exit(load_entry_point('parallel-bilby==0.1.4', 'console_scripts', 'parallel_bilby_analysis')())
File "/fred/oz170/rsmith/anaconda3/envs/pbilby_exp/lib/python3.6/site-packages/pkg_resources/__init__.py", line 488, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/fred/oz170/rsmith/anaconda3/envs/pbilby_exp/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2861, in load_entry_point
return ep.load()
File "/fred/oz170/rsmith/anaconda3/envs/pbilby_exp/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2461, in load
return self.resolve()
File "/fred/oz170/rsmith/anaconda3/envs/pbilby_exp/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2467, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/fred/oz170/rsmith/anaconda3/envs/pbilby_exp/lib/python3.6/site-packages/parallel_bilby-0.1.4-py3.6.egg/parallel_bilby/analysis.py", line 421, in <module>
for it, res in enumerate(sampler.sample(**sampler_kwargs)):
File "/fred/oz170/rsmith/anaconda3/envs/pbilby_exp/lib/python3.6/site-packages/dynesty-1.0.1-py3.6.egg/dynesty/sampler.py", line 782, in sample
u, v, logl, nc = self._new_point(loglstar_new, logvol)
File "/fred/oz170/rsmith/anaconda3/envs/pbilby_exp/lib/python3.6/site-packages/dynesty-1.0.1-py3.6.egg/dynesty/sampler.py", line 393, in _new_point
if logl >= loglstar:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I think the amount of code changes should be minimal. It's probably just a matter of appending lists correctly.
Edited by Rory Smith