statistics.py 文件源码

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

项目:nanopores 作者: mitschabaude 项目源码 文件源码
def sample_scalar(self, shape, a):
        AMAX = 30
        if a > AMAX:
            return np.random.poisson(a, shape)
        k = 1
        K = np.full(shape, k)
        s = a/np.expm1(a)
        S = s
        U = np.random.random(shape)
        new = S < U
        while np.any(new):
            k += 1
            K[new] = k
            s = s*a/float(k)
            S = S + s
            new = S < U
        return K
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号