distribution.py 文件源码

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

项目:markov-sentence-correction 作者: anassinator 项目源码 文件源码
def poisson_distribution(gamma):
    """Computes the probability of events for a Poisson distribution.

    Args:
        gamma: The average number of events to occur in an interval.

    Returns:
        The probability distribution of k events occuring.
        This is a function taking one parameter (k) and returning the
        probability of k events occuring.
    """
    constant_factor = math.e ** (-gamma)

    def probability(k):
        """The probability of k events occuring for a Poisson distribution.

        Args:
            k: The number of the events occuring in an interval.

        Returns:
            The probability of k events occuring in the given distribution.
        """
        return (constant_factor * gamma ** k) / (math.factorial(k))

    return probability
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号