數學——泊松分布、指數分布
阿新 • • 發佈:2019-02-17
poisson ima blog size 小時 pre ont new index
1、泊松分布
獨立隨機事件X,在某段時間內發生次數的期望lambda已知,求發生次數為k的概率
例如:某醫院平均每天出生10個嬰兒,我們現在想知道明天出生多少嬰兒(明天出生k個嬰兒的概率)
2、指數分布
獨立隨機事件X,在某段時間內發生次數的期望lambda已知,事件下一次發生的時間間隔為x的概率
例如:某醫院平均每天出生10個嬰兒,我們現在想知道下一個嬰兒什麽時候出生(x小時後有嬰兒出生的概率)
3、泊松分布與指數分布的關系
泊松分布:在某段時間內事件發生的概率
指數分布:事件發生時間間隔為t的概率
事件發生的時間間隔大於t,就相當於從現在開始t小時內,該事件不會發生
4、exp(x)的Taylor展開
5、泊松分布中,P隨k、lambda變化的關系
import math
import numpy as np
import matplotlib.pyplot as plt
def fac(x):
if x == 0:
return 1
if x == 1:
return 1
return x*fac(x-1)
#固定k,變化lambda
plt.figure()
x = np.arange(0,10,0.05)
for i in range(5):
y = [math.exp(-a)*a**i/fac(i) for a in x]
plt.plot(x,y,linewidth=2,label=‘k=‘+ str(i))
plt.grid(True)
plt.legend(loc=‘upper right‘)
plt.xlabel(‘lambda‘)
plt.ylabel(‘P‘)
#固定lambda,變化k
plt.figure()
x = np.arange(0,10,1)
for i in range(1,6):
y = [i**a/fac(a)*math.exp(-i) for a in x]
plt.plot(x,y,linewidth=2,label=‘lambda=‘+ str(i))
plt.grid(True)
plt.legend(loc =‘upper right‘)
plt.xlabel(‘k‘)
plt.ylabel(‘P‘)
參考:
http://www.ruanyifeng.com/blog/2015/06/poisson-distribution.html
https://www.zhihu.com/question/26441147
http://episte.math.ntu.edu.tw/articles/sm/sm_16_07_1/index.html
數學——泊松分布、指數分布