I have a doubt about the implementation of the stretch move: in both
Goodman & Weare (2010) and
Foreman-Mackey et al. (2013) the density distribution g(
z) of the scaling variable Z is chosen as proportional to 1/sqrt(
z) with
z in the range [1/a, a], with a an arbitrary constant, by default set to 2.
From what I understand, the sampling of this distribution is implemented in line 30 of "
emcee/
src/
emcee/
moves/stretch.py" :
zz = ((self.a - 1.0) * random.rand(Ns) + 1) ** 2.0 / self.a
where the random variable is the z of the papers.
I have a hard time figuring out how to map this expression to one proportional to 1/sqrt(z), even looking at the following lines (31-33), where nothing else seems to happen to the variable zz before the actual move proposal:
factors = (ndim - 1.0) * np.log(zz)
rint = random.randint(Nc, size=(Ns,))
return c[rint] - (c[rint] - s) * zz[:, None], factors
Wouldn't the following edit of line 30 be more consistent with the distribution discussed in the papers?
Z = random.uniform(1.0/self.a, self.a, Ns)
zz = 1.0 / np.sqrt(Z)
Thank you in advance, any help would be highly appreciated!