RateDistribution.py 文件源码

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

项目:EndemicPy 作者: j-i-l 项目源码 文件源码
def __init__(self, scale, pre=10):
        """
        This class holds a queue of times drawn from an exponential 
            distribution with a specified scale.

        Arguments:

            - scale: The scale parameter for the exponential distribution.
            - pre: Predefined size of the queue. Default=10
        """
        self.scale = scale
        self.pre = pre
        self.queue = SimpleQueue(maxsize=pre + 1)
        self.v_put = vectorize(self.queue.put_nowait)
        #the exponential dist is not defined for a rate of 0
        #therefore if the rate is 0 (scale is None then) huge times are set
        if self.scale in [None, 0]:
            self.scale = 0
            self.draw_fct = no_mut
        else:
            self.draw_fct = random.exponential
        #fillup the queue
        self.fillup()
        # there was: (new version compatible with pickeling see method below)
        self.v_get = vectorize(self.get_val)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号