nestedsamplers.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:dynesty 作者: joshspeagle 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号