def propose_unif(self):
"""Propose a new live point by sampling *uniformly* within
the collection of N-cubes 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-cubes along with the
# number of overlapping cubes `q` at point `u`.
u, q = self.supfriends.sample(self.live_u, rstate=self.rstate,
return_q=True, kdtree=kdtree)
# Check if our point is within the unit cube.
if self._check_unit_cube(u):
# Accept the point with probability 1/q to account for
# overlapping cubes.
if q == 1 or self.rstate.rand() < 1.0 / q:
break # if successful, we're done!
# Define the axes of our N-cube.
ax = np.identity(self.npdim) * self.supfriends.hside
return u, ax
评论列表
文章目录