Python Data Science 简明教程

Python - Poisson Distribution

泊松分布是一种分布,它显示了在预先确定的时间段内事件发生次数的可能性。它用于在给定的时间间隔内以恒定速率发生的独立事件。泊松分布是一个离散函数,这意味着此事件只能测量为发生或未发生,也就是说此变量只能测量为整数。

A Poisson distribution is a distribution which shows the likely number of times that an event will occur within a pre-determined period of time. It is used for independent events which occur at a constant rate within a given interval of time. The Poisson distribution is a discrete function, meaning that the event can only be measured as occurring or not as occurring, meaning the variable can only be measured in whole numbers.

我们使用 seaborn python 库,它具有创建此类概率分布图形的内置函数。此外,scipy 包有助于创建二项分布。

We use the seaborn python library which has in-built functions to create such probability distribution graphs. Also the scipy package helps is creating the binomial distribution.

from scipy.stats import poisson
import seaborn as sb

data_binom = poisson.rvs(mu=4, size=10000)
ax = sb.distplot(data_binom,
                  kde=True,
                  color='green',
                  hist_kws={"linewidth": 25,'alpha':1})
ax.set(xlabel='Poisson', ylabel='Frequency')

它的 output 如下所示 −

Its output is as follows −

poissondist