def propose_unif(self):
"""Propose a new live point by sampling *uniformly* within
the union of N-spheres defined by our live points."""
# Initialize a K-D Tree to assist nearest neighbor searches.
kdtree = spatial.KDTree(self.live_u)
while True:
# Sample a point `u` from the union of N-spheres along with the
# number of overlapping spheres `q` at point `u`.
u, q = self.radfriends.sample(self.live_u, rstate=self.rstate,
return_q=True, kdtree=kdtree)
# Check if our sample is within the unit cube.
if self._check_unit_cube(u):
# Accept the point with probability 1/q to account for
# overlapping balls.
if q == 1 or self.rstate.rand() < 1.0 / q:
break # if successful, we're done!
# Define the axes of the N-sphere.
ax = np.identity(self.npdim) * self.radfriends.radius
return u, ax
评论列表
文章目录