b:head_first_statistics:geometric_binomial_and_poisson_distributions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
b:head_first_statistics:geometric_binomial_and_poisson_distributions [2023/10/16 08:38] – [From a scratch (Proof of Binomial Expected Value)] hkimscil | b:head_first_statistics:geometric_binomial_and_poisson_distributions [2023/10/19 19:00] (current) – [Geometric Binomial and Poisson Distributions] hkimscil | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Geometric Binomial and Poisson Distributions ====== | ====== Geometric Binomial and Poisson Distributions ====== | ||
+ | 정리 | ||
+ | \begin{align*} | ||
+ | \text{Geometric Distribution: | ||
+ | p(X = k) & = q^{k-1} \cdot p \\ | ||
+ | E\left[ X \right] & = \frac{1}{p} \\ | ||
+ | V\left[ X \right] & = \frac{q}{p^2} \\ | ||
+ | \\ | ||
+ | \text{Binomial Distribution: | ||
+ | p(X = r) & = \binom{n}{r} \cdot p^{r} \cdot q^{n-r} \\ | ||
+ | E\left[ X \right] & = {n}{p} \\ | ||
+ | V\left[ X \right] & = {n}{p}{q} \\ | ||
+ | \\ | ||
+ | \text{Poisson Distribution: | ||
+ | P(X=r) & = e^{- \lambda} \cdot \dfrac{\lambda^{r}} {r!} \\ | ||
+ | E\left[ X \right] & = \lambda \\ | ||
+ | V\left[ X \right] & = \lambda \\ | ||
+ | \end{align*} | ||
+ | |||
===== Geometric Distributions ===== | ===== Geometric Distributions ===== | ||
Line 924: | Line 942: | ||
==== From a scratch (Proof of Binomial Expected Value) ==== | ==== From a scratch (Proof of Binomial Expected Value) ==== | ||
- | see [[:The Binomial | + | [[:Mean and Variance of Binomial |
- | + | ||
- | \begin{eqnarray*} | + | |
- | \text{The binomial theorem} & & \\ | + | |
- | (a + b)^{m} & = & \sum^{m}_{y=0}{{m}\choose{y}} a^{m-y} b^{y} \\ | + | |
- | \end{eqnarray*} | + | |
- | + | ||
- | 위의 식이 복잡해 보이지만 m = 3 일때의 이항정리식을 말한다 | + | |
- | \begin{align*} | + | |
- | \sum^{m}_{y=0}{{m}\choose{y}} a^{m-y} b^{y} \text{, m = 3} \\ | + | |
- | \end{align*} | + | |
- | + | ||
- | \begin{align*} | + | |
- | \sum^{3}_{y=0}{{3}\choose{y}} a^{3-y} b^{y} | + | |
- | & = {{3}\choose{0}} a^{3-0} b^{0} | + | |
- | + {{3}\choose{1}} a^{3-1} b^{1} | + | |
- | + {{3}\choose{2}} a^{3-2} b^{2} | + | |
- | + {{3}\choose{3}} a^{3-3} b^{3} \\ | + | |
- | & = 1*a^3*b^0 | + | |
- | + 3*a^2*b^1 | + | |
- | + 3*a^1*b^2 | + | |
- | + 1*a^0*b^3 | + | |
- | & = a^3 | + | |
- | + 3 a^2 b^1 | + | |
- | + 3 a^1 b^2 | + | |
- | + b^3 \\ | + | |
- | \end{align*} | + | |
- | + | ||
- | + | ||
- | ==== For Mean ==== | + | |
- | \begin{eqnarray*} | + | |
- | E(X) & = & \sum_{x}x p(x) \\ | + | |
- | & = & \sum_{x=0}^{n} x {{n}\choose {x}} p^x(1-p)^{n-x} | + | |
- | & = & \sum_{x=0}^{n} x \frac{n!}{x!(n-x)!} p^x(1-p)^{n-x} | + | |
- | \text{note that } x! = x(x-1)! \\ | + | |
- | & = & \sum_{x=1}^{n} \frac{n!}{(x-1)!(n-x)!} p^x(1-p)^{n-x} | + | |
- | \text{cause we know that E(x) = np,} \\ | + | |
- | \text{we extract np outside from summation} \\ | + | |
- | \text{note that } p^x = p * p^{x-1} \\ | + | |
- | \text{and } n! = n * (n-1)! \\ | + | |
- | & = & \sum_{x=1}^{n} \frac{\underline{n}*(n-1)!}{(x-1)!(n-x)!} (\underline{p}*p^{x-1})(1-p)^{n-x} | + | |
- | \text{we take out the underlined part} \\ | + | |
- | \text{(that is, np) out of the sigma part } \\ | + | |
- | & = & np \sum_{x=1}^{n} \frac{(n-1)!}{(x-1)!(n-x)!} p^{x-1}(1-p)^{n-x} | + | |
- | & = & np \underline{ \sum_{x=1}^{n} {\frac{(n-1)!}{(x-1)!(n-x)!} p^{x-1}(1-p)^{n-x}}} | + | |
- | \text{we want to check the underlined} \\ | + | |
- | \text{part is equal to one so that np is left out} \\ | + | |
- | n-x = (n-1)-(x-1) \\ | + | |
- | & = & np \sum_{x=1}^{n} \frac{(n-1)!}{(x-1)!((n-1)-(x-1))!} p^{x-1}(1-p)^{(n-1)-(x-1)} | + | |
- | m = n - 1 \\ | + | |
- | y = x - 1 \\ | + | |
- | & = & np \sum_{y=0}^{m} \frac{(m)!}{(y)!(m-y))!} p^{y}(1-p)^{(m-y)} | + | |
- | & = & np \sum_{y=0}^{m} \frac{(m)!}{(y)!(m-y))!} p^{y}(1-p)^{(m-y)} | + | |
- | & = & np \sum_{y=0}^{m} {{m}\choose {y}} p^{y}(1-p)^{(m-y)} | + | |
- | \text{Recall that} \\ | + | |
- | \sum^{m}_{y=0}{{m}\choose{y}} a^{y} b^{m-y} = (a + b)^{m} \\ | + | |
- | & = & np (p + (1-p))^m | + | |
- | & = & np (1)^m \\ | + | |
- | & = & np \\ | + | |
- | \end{eqnarray*} | + | |
- | + | ||
- | ==== For variance ==== | + | |
- | \begin{align*} | + | |
- | Var(X) & = E[(X-\mu)^2] \\ | + | |
- | & = \sum_{x}(x-\mu)^2p(x) \\ | + | |
- | \text{We also know that: } \\ | + | |
- | E[(X-\mu)^2] & = E(X^2) - [E(X)]^2 \\ | + | |
- | \end{align*} | + | |
- | + | ||
- | \begin{align*} | + | |
- | E(X^2) & = \sum_{x=0}^{n} x^2 {{n}\choose{x}} p^x (1-p)^{n-x} \\ | + | |
- | & = \sum_{x=0}^{n} x^2 \frac{n!}{x!(n-x)!} p^x (1-p)^{n-x} \\ | + | |
- | \end{align*} | + | |
- | + | ||
- | 그런데 $E(X^2)$ 대신 $E[X(X-1)]$을 생각해보면 | + | |
- | + | ||
- | \begin{align*} | + | |
- | E[X(X-1)] & = \sum_{x=0}^{n} x(x-1) \frac{n!}{x!(n-x)!} p^x (1-p)^{n-x} \\ | + | |
- | & = \sum_{x=2}^{n} \frac{n!}{(x-2)!(n-x)!} p^x (1-p)^{n-x} \\ | + | |
- | & = n(n-1)p^2 \sum_{x=2}^{n} \frac{(n-2)!}{(x-2)!(n-x)!} p^{x-2} (1-p)^{n-x} \\ | + | |
- | \text{cause} \\ | + | |
- | n - x = (n - 2)-(x - 2) \\ | + | |
- | & = n(n-1)p^2 \sum_{x=2}^{n} \frac{(n-2)!}{(x-2)!((n-2)-(x-2))!} p^{x-2} (1-p)^{(n-2)-(x-2)} \\ | + | |
- | m = n - 2 \\ | + | |
- | y = x - 2 \\ | + | |
- | & = n(n-1)p^2 \sum_{y=0}^{m} \frac{m!}{y!((m-y))!} p^{y} (1-p)^{(m-y)} \\ | + | |
- | & = n(n-1)p^2 \underline {\sum_{y=0}^{m} \frac{m!}{y!((m-y))!} p^{y} (1-p)^{m-y} } \\ | + | |
- | & = n(n-1)p^2 \underline {\sum_{y=0}^{m} {{m}\choose{y}} p^{y} (1-p)^{m-y} } \\ | + | |
- | + | ||
- | \text {we know that the underline part is} \\ | + | |
- | (p+(1-p))^m = 1^m \\ | + | |
- | & = n(n-1)p^2 (p + (1-p))^m \\ | + | |
- | & = n(n-1)p^2 \\ | + | |
- | \end{align*} | + | |
- | . . . . | + | |
- | \begin{align*} | + | |
- | E[X(X - 1)] & = n(n-1)p^2 \\ | + | |
- | E[X^2 - X] & = n(n-1)p^2 \\ | + | |
- | E[X^2]- E[X] & = n(n-1)p^2 \\ | + | |
- | E[X^2]- np & = n(n-1)p^2 \\ | + | |
- | E[X^2]& = n(n-1)p^2 + np \\ | + | |
- | \\ | + | |
- | \end{align*} | + | |
- | + | ||
- | \begin{align*} | + | |
- | Var(X) & = E[X^2] - [E(X)]^2 | + | |
- | & = \left[n(n-1)p^2 + np \right] - \left[np \right]^2 | + | |
- | & = np[(n-1)p + 1 - np] \\ | + | |
- | & = np[np - p + 1 - np] \\ | + | |
- | & = np(1 - p) \\ | + | |
- | & = npq \\ | + | |
- | \\ | + | |
- | \end{align*} | + | |
- | + | ||
- | + | ||
====== Poisson Distribution ====== | ====== Poisson Distribution ====== | ||
$$X \sim Po(\lambda)$$ | $$X \sim Po(\lambda)$$ | ||
Line 1110: | Line 1013: | ||
> plot(dpois(x=1: | > plot(dpois(x=1: | ||
> </ | > </ | ||
+ | |||
+ | 위에서 언급한 | ||
+ | |||
+ | \begin{eqnarray*} | ||
+ | \sum_{r=0}^{\infty} e^{- \lambda} \dfrac{\lambda^{r}} {r!} | ||
+ | & = & e^{- \lambda} \sum_{r=0}^{\infty} \dfrac{\lambda^{r}} {r!} \\ | ||
+ | & = & e^{- \lambda} \left(1 + \lambda + \dfrac{\lambda^{2}}{2!} + \dfrac{\lambda^{3}}{3!} + . . . \right) \\ | ||
+ | & = & e^{- \lambda}e^{\lambda} \\ | ||
+ | & = & 1 | ||
+ | \end{eqnarray*} | ||
+ | |||
+ | 에서 1 이란 이야기는 아래 그림의 그래프가 전체가 1이 됨을 의미함. 즉 위에서는 1부터 60까지 갔지만, 1부터 무한대로 하면 완전한 분포곡선이 되는데 이것이 1이라는 뜻 (가령 dpois(x=1: | ||
+ | |||
+ | |||
[{{: | [{{: | ||
Line 1182: | Line 1099: | ||
> dpois(x=3, lambda=3.4) | > dpois(x=3, lambda=3.4) | ||
[1] 0.2186172 | [1] 0.2186172 | ||
+ | </ | ||
+ | |||
+ | 마찬가지로 적어도 3번까지 고장나는 경우는 0, 1, 2, 3을 포함하므로 | ||
+ | < | ||
+ | > sum(dpois(c(0: | ||
+ | [1] 0.5583571 | ||
+ | > | ||
</ | </ | ||
Line 1268: | Line 1192: | ||
> a*b*c | > a*b*c | ||
[1] 0.03268244 | [1] 0.03268244 | ||
+ | > | ||
+ | </ | ||
+ | 위가 답이긴 하지만 limited calculator 로는 | ||
+ | x ~ b (n, p)이고 | ||
+ | b(100, 0.1)이므로 | ||
+ | n*p = 10 = lambda | ||
+ | 따라서 | ||
+ | < | ||
+ | > dpois(x=15, lambda=10) | ||
+ | [1] 0.03471807 | ||
> | > | ||
</ | </ |
b/head_first_statistics/geometric_binomial_and_poisson_distributions.1697413115.txt.gz · Last modified: 2023/10/16 08:38 by hkimscil