# 布瓦松分布 (Poisson distribution)

• 意義：在單位時間內，事件出現平均 λ 次的機率分布。
• 課本公式：
(1)
\begin{align} f(x) = \frac{e^{-k} k^x}{x!} \end{align}
• R 的公式：p(x) = λ^x e^{-λ}/x!
(2)
\begin{align} pois(λ) = \frac{λ^x e^{-λ}}{x!} \end{align}
• 變數意義：k = λ;

# 特性

If the Taylor series is centered at zero, then that series is also called a Maclaurin series, named after the Scottish mathematician Colin Maclaurin, who made extensive use of this special case of Taylor series in the 18th century.

(3)
$$e^x = 1+x+x^2/2!+x^3/3!+ ... + x^k/k! + ....$$

# 布瓦松分配的公式來源

(4)
\begin{align} \lim_{n\to\infty}\left(1-{\lambda \over n}\right)^n=e^{-\lambda} \end{align}

(5)
\begin{eqnarray} \lim_{n\to\infty} P(X_n=k) &=& \lim_{n\to\infty}{n \choose k} p^k (1-p)^{n-k} \\ &=&\lim_{n\to\infty}{n! \over (n-k)!k!} \left({\lambda \over n}\right)^k \left(1-{\lambda\over n}\right)^{n-k}\\ &=&\lim_{n\to\infty} \underbrace{\left[\frac{n!}{n^k\left(n-k\right)!}\right]}_{A_n} \left(\frac{\lambda^k}{k!}\right) \underbrace{\left(1-\frac{\lambda}{n}\right)^n}_{\to\exp\left(-\lambda\right)} \underbrace{\left(1-\frac{\lambda}{n}\right)^{-k}}_{\to 1} \\ &=& \left[ \lim_{n\to\infty} A_n \right] \left(\frac{\lambda^k}{k!}\right)\exp\left(-\lambda\right) \\ &\to& \left(\frac{\lambda^k}{k!}\right)\exp\left(-\lambda\right) \end{eqnarray}

(6)
\begin{eqnarray} A_n &=& \frac{n!}{n^k\left(n-k\right)!}\\ &=& \frac{n\cdot (n-1)\cdots \big(n-(k-1)\big)}{n^k}\\ &=& 1\cdot(1-\tfrac{1}{n})\cdots(1-\tfrac{k-1}{n})\\ &\to & 1\cdot 1\cdots 1 = 1 \end{eqnarray}

# 期望值與變異數

(7)
\begin{eqnarray} 1. && E(X) = k = λ \\ 2. && Var(X) = k = λ \end{eqnarray}

# 動差生成函數

(8)
$$m_x(t) = e^{k (e^t-1) } = e^{λ (e^t-1) }$$

# R 程式範例一

lambda=5.0; k=seq(0,20);
plot(k, dpois(k, lambda), type='h', main='dpois(lambda=4.0)', xlab='k')


# R 程式範例二

require(graphics)

-log(dpois(0:7, lambda=1) * gamma(1+ 0:7)) # == 1
Ni <- rpois(50, lambda = 4); table(factor(Ni, 0:max(Ni)))

1 - ppois(10*(15:25), lambda=100)  # becomes 0 (cancellation)
ppois(10*(15:25), lambda=100, lower.tail=FALSE)  # no cancellation

par(mfrow = c(2, 1))
x <- seq(-0.01, 5, 0.01)
plot(x, ppois(x, 1), type="s", ylab="F(x)", main="Poisson(1) CDF")
plot(x, pbinom(x, 100, 0.01),type="s", ylab="F(x)",
main="Binomial(100, 0.01) CDF")


> require(graphics)
>
> -log(dpois(0:7, lambda=1) * gamma(1+ 0:7)) # == 1
[1] 1 1 1 1 1 1 1 1
> Ni <- rpois(50, lambda = 4); table(factor(Ni, 0:max(Ni)))

0  1  2  3  4  5  6  7  8
1  3  6  8 11 11  4  3  3
>
> 1 - ppois(10*(15:25), lambda=100)  # becomes 0 (cancellation)
[1] 1.233094e-06 1.261664e-08 7.085799e-11 2.252643e-13 4.440892e-16
[6] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
[11] 0.000000e+00
>     ppois(10*(15:25), lambda=100, lower.tail=FALSE)  # no cancellation
[1] 1.233094e-06 1.261664e-08 7.085800e-11 2.253110e-13 4.174239e-16
[6] 4.626179e-19 3.142097e-22 1.337219e-25 3.639328e-29 6.453883e-33
[11] 7.587807e-37
>
> par(mfrow = c(2, 1))
> x <- seq(-0.01, 5, 0.01)
> plot(x, ppois(x, 1), type="s", ylab="F(x)", main="Poisson(1) CDF")
> plot(x, pbinom(x, 100, 0.01),type="s", ylab="F(x)",
+      main="Binomial(100, 0.01) CDF")
>