User Tools

Site Tools


b:head_first_statistics:geometric_binomial_and_poisson_distributions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
b:head_first_statistics:geometric_binomial_and_poisson_distributions [2019/11/07 10:26] – [What does the Poisson distribution look like?] hkimscilb: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:  } \;\;\; \text{X} & \thicksim Geo(p) \\
 +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:  } \;\;\; \text{X} & \thicksim B(n, p) \\
 +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:  } \;\;\; \text{X} & \thicksim P( \lambda ) \\
 +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 69: Line 87:
 [29] 0.0003868563 0.0003094850  [29] 0.0003868563 0.0003094850 
  
-> hist(dgeom(x = 0:n, prob = p))</code>+> hist(dgeom(x = 0:n, prob = p))
 </code> </code>
  
 {{:b:head_first_statistics:pasted:20191030-023820.png}} {{:b:head_first_statistics:pasted:20191030-023820.png}}
  
-r번 시도한 에 첫번 째 성공을 얻을 확률+r번 시도한 다음에 성공을 얻을 확률
 첫 번째 성공을 얻을 때까지 r번 이상 시도를 해야하는 확률 첫 번째 성공을 얻을 때까지 r번 이상 시도를 해야하는 확률
 $$ P(X > r) = q^{r} $$ $$ P(X > r) = q^{r} $$
 +
 20번 시도 후에 어디선가 성공할 확률은?  20번 시도 후에 어디선가 성공할 확률은? 
-20번까지는 실패하는 확률 = $q^{r} $ 
  
-{{:b:head_first_statistics:pasted:20191031-004954.png}}+Solution.  
 +  * 21번째 성공 + 22번째 + 23번째 + . . . .  
 +  * 위는 구할 수 없음 
 +  * 따라서 
 +  * 1 (1번째 성공 + 2번째 성공 + . . + 20번째 성공) 
 +  * 그런데 이것은  
 +  * 20번까지는 실패하는 확률 = $q^{r$ 과 같다 
 +<code> 
 +p <- .2 
 +q <- 1-p 
 +n <- 19 
 +s <- dgeom(x = 0:n, prob = p) 
 +# 20번째까지 성공할 확률 
 +sum(s) 
 +# 따라서 아래는 20번 이후에 성공할 확률 
 +1-sum(s) 
 +## 혹은 (교재가 이야기하는) 20번까지 실패하는 확률 
 +q^20 
 +</code>
  
 +<code>
 +> p <- .2
 +> q <- 1-p
 +> n <- 19
 +> s <- dgeom(x = 0:n, prob = p)
 +> # 20번째까지 성공할 확률
 +> sum(s)
 +[1] 0.9884708
 +> # 따라서 아래는 20번 이후에 성공할 확률
 +> 1-sum(s)
 +[1] 0.01152922
 +> ## 혹은 (교재가 이야기하는) 20번까지 실패하는 확률
 +> q^20
 +[1] 0.01152922
 +
 +</code>
 +{{:b:head_first_statistics:pasted:20191031-004954.png}}
  
 +그렇다면 
 r 번 이전에 성공이 있을 확률은? = r 번까지의 실패할 확률의 보수 r 번 이전에 성공이 있을 확률은? = r 번까지의 실패할 확률의 보수
 $$ P(X \le r) = 1 - q^{r} $$ $$ P(X \le r) = 1 - q^{r} $$
 +
 +혹은 1번째 성공 + 2번째 성공 + . . . + r 번째 성공으로 구해도 된다
 +<code>
 +# r = 20 이라고 하면 
 +p <- .2
 +q <- 1-p
 +n <- 19
 +s <- dgeom(x = 0:n, prob = p)
 +sum(s)
 +</code>
 +
 +
 {{:b:head_first_statistics:pasted:20191031-005143.png}} {{:b:head_first_statistics:pasted:20191031-005143.png}}
  
Line 93: Line 159:
  
 ===== Expected value ===== ===== Expected value =====
-Reminding . . . +X가 성공할 확률 p를 가진 Geometric distribution을 따른다  :: $X \sim \text{Geo}(p)$ 
 + 
 +Reminding . . . [[:b/head_first_statistics/using_discrete_probability_distributions#expected_value_discrete_prob|Expected value in discrete probability]]
 $E(X) = \sum x*P(X=x)$ $E(X) = \sum x*P(X=x)$
  
-| textbook  | x  | P(X = x)  | xP(X = x)  | xP(X ≤ x): \\  $E(X) = \sum x*P(X=x)$  |+| textbook  | x  | P(X = x)  | xP(X = x)  | xP(X ≤ x): \\  $E(X) = \sum (x*P(X=x))$  |
 | r code  | trial  | ''px <- q^(trial-1)*p''  | ''npx <- trial*(q^(trial-1))*p''  |  ''plex <- cumsum(trial*(q^(trial-1))*p)''  | | r code  | trial  | ''px <- q^(trial-1)*p''  | ''npx <- trial*(q^(trial-1))*p''  |  ''plex <- cumsum(trial*(q^(trial-1))*p)''  |
 +|     | ''px''   | ''npx <- trial*px''   | ''plex <- cumsum(npx)''   |
 +|     | x번째 (trial번째) \\ 성공할 확률  | x번째의 기대치 \\ (주사위 경우처럼)  | 그 x번째까지 성공할 \\ 확률에 대한 기대값  |
 +
 +
  
 <code> <code>
 p <- .2 p <- .2
 q <- 1-p q <- 1-p
-trial <- c(1,2,3,4,5,6,7,8)+trial <- c(1:8)
 px <- q^(trial-1)*p px <- q^(trial-1)*p
 px px
-npx <- trial*(q^(trial-1))*p+## npx <- trial*(q^(trial-1))*p 
 +## 위는 아래와 같음
 npx <- trial*px npx <- trial*px
 npx npx
-plex <- cumsum(trial*(q^(trial-1))*p)+## plex <- cumsum(trial*(q^(trial-1))*p
 +## 위는 아래와 같음 
 +plex <- cumsum(npx)
 plex plex
 sumgeod <- data.frame(trial,px,npx,plex) sumgeod <- data.frame(trial,px,npx,plex)
Line 139: Line 214:
 8     8 0.042 0.336 2.819 8     8 0.042 0.336 2.819
  
-</code> 
- 
-<code> 
-p <- .2 
-q <- 1-p 
-trial <- c(1:100) 
-px <- q^(trial-1)*p 
-px 
-npx <- trial*(q^(trial-1))*p 
-npx 
-plex <- cumsum(trial*(q^(trial-1))*p) 
-plex 
-sumgeod <- data.frame(trial,px,npx,plex) 
-round(sumgeod,3) 
-plot(npx, type="l") 
-plot(plex, type="l") 
 </code> </code>
  
Line 162: Line 221:
 > trial <- c(1:100) > trial <- c(1:100)
 > px <- q^(trial-1)*p > px <- q^(trial-1)*p
-> px +round(px, 3) 
-  [1] 2.000000e-01 1plot(plex, type="l").600000e-01 1.280000e-01 1.024000e-01 8.192000e-02 6.553600e-02 5.242880e-02 +  [1] 0.200 0.160 0.128 0.102 0.082 0.066 0.052 0.042 0.034 0.027 0.021 0.017 
-  [84.194304e-02 3.355443e-02 2.684355e-02 2.147484e-02 1.717987e-02 1.374390e-02 1.099512e-02 + [130.014 0.011 0.009 0.007 0.006 0.005 0.004 0.003 0.002 0.002 0.001 0.001 
- [158.796093e-03 7.036874e-03 5.629500e-03 4.503600e-03 3.602880e-03 2.882304e-03 2.305843e-03 + [250.001 0.001 0.001 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [22] 1.844674e-03 1.475740e-03 1.180592e-03 9.444733e-04 7.555786e-04 6.044629e-04 4.835703e-04 + [370.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [293.868563e-04 3.094850e-04 2.475880e-04 1.980704e-04 1.584563e-04 1.267651e-04 1.014120e-04 + [490.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [36] 8.112964e-05 6.490371e-05 5.192297e-05 4.153837e-05 3.323070e-05 2.658456e-05 2.126765e-05 + [610.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [431.701412e-05 1.361129e-05 1.088904e-05 8.711229e-06 6.968983e-06 5.575186e-06 4.460149e-06 + [730.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [50] 3.568119e-06 2.854495e-06 2.283596e-06 1.826877e-06 1.461502e-06 1.169201e-06 9.353610e-07 + [85] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [577.482888e-07 5.986311e-07 4.789049e-07 3.831239e-07 3.064991e-07 2.451993e-07 1.961594e-07 + [970.000 0.000 0.000 0.000
- [64] 1.569275e-07 1.255420e-07 1.004336e-07 8.034690e-08 6.427752e-08 5.142202e-08 4.113761e-08 +
- [713.291009e-08 2.632807e-08 2.106246e-08 1.684997e-08 1.347997e-08 1.078398e-08 8.627183e-09 +
- [78] 6.901746e-09 5.521397e-09 4.417118e-09 3.533694e-09 2.826955e-09 2.261564e-09 1.809251e-09 +
- [85] 1.447401e-09 1.157921e-09 9.263367e-10 7.410694e-10 5.928555e-10 4.742844e-10 3.794275e-10 +
- [92] 3.035420e-10 2.428336e-10 1.942669e-10 1.554135e-10 1.243308e-10 9.946465e-11 7.957172e-11 +
- [996.365737e-11 5.092590e-11+
 > npx <- trial*(q^(trial-1))*p > npx <- trial*(q^(trial-1))*p
-> npx +round(npx, 3) 
-  [1] 2.000000e-01 3.200000e-01 3.840000e-01 4.096000e-01 4.096000e-01 3.932160e-01 3.670016e-01 +  [1] 0.200 0.320 0.384 0.410 0.410 0.393 0.367 0.336 0.302 0.268 0.236 0.206 
-  [83.355443e-01 3.019899e-01 2.684355e-01 2.362232e-01 2.061584e-01 1.786706e-01 1.539316e-01 + [130.179 0.154 0.132 0.113 0.096 0.081 0.068 0.058 0.048 0.041 0.034 0.028 
- [151.319414e-01 1.125900e-01 9.570149e-02 8.106479e-02 6.845471e-02 5.764608e-02 4.842270e-02 + [250.024 0.020 0.016 0.014 0.011 0.009 0.008 0.006 0.005 0.004 0.004 0.003 
- [22] 4.058284e-02 3.394201e-02 2.833420e-02 2.361183e-02 1.964504e-02 1.632050e-02 1.353997e-02 + [370.002 0.002 0.002 0.001 0.001 0.001 0.001 0.001 0.000 0.000 0.000 0.000 
- [291.121883e-02 9.284550e-03 7.675228e-03 6.338253e-03 5.229059e-03 4.310012e-03 3.549422e-03 + [490.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [36] 2.920667e-03 2.401437e-03 1.973073e-03 1.619997e-03 1.329228e-03 1.089967e-03 8.932412e-04 + [610.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [437.316071e-04 5.988970e-04 4.900066e-04 4.007165e-04 3.275422e-04 2.676089e-04 2.185473e-04 + [730.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [50] 1.784060e-04 1.455793e-04 1.187470e-04 9.682448e-05 7.892109e-05 6.430607e-05 5.238022e-05 + [85] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 
- [574.265246e-05 3.472060e-05 2.825539e-05 2.298743e-05 1.869645e-05 1.520236e-05 1.235804e-05 + [970.000 0.000 0.000 0.000
- [64] 1.004336e-05 8.160232e-06 6.628619e-06 5.383242e-06 4.370871e-06 3.548119e-06 2.879633e-06 +
- [712.336616e-06 1.895621e-06 1.537559e-06 1.246898e-06 1.010998e-06 8.195824e-07 6.642931e-07 +
- [78] 5.383362e-07 4.361904e-07 3.533694e-07 2.862292e-07 2.318103e-07 1.877098e-07 1.519771e-07 +
- [85] 1.230291e-07 9.958120e-08 8.059129e-08 6.521410e-08 5.276414e-08 4.268560e-08 3.452790e-08 +
- [92] 2.792587e-08 2.258353e-08 1.826109e-08 1.476428e-08 1.193576e-08 9.648071e-09 7.798028e-09 +
- [996.302080e-09 5.092590e-09+
 > plex <- cumsum(trial*(q^(trial-1))*p) > plex <- cumsum(trial*(q^(trial-1))*p)
-> plex +round(plex, 3) 
-  [1] 0.200000 0.520000 0.904000 1.313600 1.723200 2.116416 2.483418 2.818962 3.120952 3.389387 +  [1] 0.200 0.520 0.904 1.314 1.723 2.116 2.483 2.819 3.121 3.389 3.626 3.832 
- [11] 3.625610 3.831769 4.010440 4.164371 4.296313 4.408903 4.504604 4.585669 4.654124 4.711770 + [13] 4.010 4.164 4.296 4.409 4.505 4.586 4.654 4.712 4.760 4.801 4.835 4.863 
- [21] 4.760192 4.800775 4.834717 4.863051 4.886663 4.906308 4.922629 4.936169 4.947388 4.956672 + [25] 4.887 4.906 4.923 4.936 4.947 4.957 4.964 4.971 4.976 4.980 4.984 4.987 
- [31] 4.964347 4.970686 4.975915 4.980225 4.983774 4.986695 4.989096 4.991069 4.992689 4.994018 + [37] 4.989 4.991 4.993 4.994 4.995 4.996 4.997 4.997 4.998 4.998 4.999 4.999 
- [41] 4.995108 4.996002 4.996733 4.997332 4.997822 4.998223 4.998550 4.998818 4.999037 4.999215 + [49] 4.999 4.999 4.999 4.999 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 
- [51] 4.999361 4.999479 4.999576 4.999655 4.999719 4.999772 4.999814 4.999849 4.999877 4.999900 + [61] 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 
- [61] 4.999919 4.999934 4.999947 4.999957 4.999965 4.999971 4.999977 4.999981 4.999985 4.999988 + [735.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 
- [714.999990 4.999992 4.999993 4.999995 4.999996 4.999997 4.999997 4.999998 4.999998 4.999998 + [855.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 
- [814.999999 4.999999 4.999999 4.999999 4.999999 5.000000 5.000000 5.000000 5.000000 5.000000 + [97] 5.000 5.000 5.000 5.000
- [91] 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000+
 > sumgeod <- data.frame(trial,px,npx,plex) > sumgeod <- data.frame(trial,px,npx,plex)
 > round(sumgeod,3) > round(sumgeod,3)
Line 315: Line 361:
 {{:b:head_first_statistics:pasted:20191031-010726.png}} {{:b:head_first_statistics:pasted:20191031-010726.png}}
 {{:b:head_first_statistics:pasted:20191031-010811.png}} {{:b:head_first_statistics:pasted:20191031-010811.png}}
 +위에서 $X \sim \text{Geo}(p)$ 일때, 기대값은 $E(X) = \displaystyle \frac{1}{p}$ 임을 알 수 있다. 아래는 그 증명이다.
  
 +===== Proof =====
 +[[:Mean and Variance of Geometric Distribution#Mean|기하분포의 기대값(expected value)]]
  
-$X \sim Geo(p)$ 일때, 기대값은 
  
-$E(X) = \displaystyle \frac{1}{p}$ +===== Variance proof ===== 
- +[[:Mean and Variance of Geometric Distribution#Variance|기하분포의 분산 증명]] 
-===== Variance =====+아래는 R에서의 시뮬레이션
 \begin{eqnarray*} \begin{eqnarray*}
 Var(X) & = & E((X-E(X))^{2}) \\ Var(X) & = & E((X-E(X))^{2}) \\
Line 335: Line 383:
 $E(X^{2}) = \sum {x^{2} * P(X=x)}$ $E(X^{2}) = \sum {x^{2} * P(X=x)}$
 왜냐하면, $E(X) = \sum {x * P(X=x)}$ 이므로  왜냐하면, $E(X) = \sum {x * P(X=x)}$ 이므로 
- 
  
 이를 구한 후에 여기에서 $E[X]^{2}$ 를 빼준 값이 Var(X) 이를 구한 후에 여기에서 $E[X]^{2}$ 를 빼준 값이 Var(X)
Line 341: Line 388:
  
 \begin{eqnarray*} \begin{eqnarray*}
-E(X)^{2} & = & (\frac{1}{p})^{2} \\+E(X)^{2} & = & \left(\frac{1}{p}\right)^{2} \\
 & = & (5^{2}) \\ & = & (5^{2}) \\
 & = & 25 & = & 25
Line 544: Line 591:
  
 </code> </code>
-위에서 보듯이 plex column에 해당하는 것이 E(X^2) 부분이고 이는 45가 된다.  
-E(X)^2 은 25이므로, Var(X) = 20이 된다. 
- 
 {{:b:head_first_statistics:pasted:20191031-062004.png}} {{:b:head_first_statistics:pasted:20191031-062004.png}}
 {{:b:head_first_statistics:pasted:20191031-062021.png}} {{:b:head_first_statistics:pasted:20191031-062021.png}}
  
-$Var(X) = \displaystyle \frac{q}{p^{2}}$+위에서 보듯이 plex column에 해당하는 것이 $E(X^2)$ 부분이고 이는 45가 된다 (45에 수렴한다). 또한 언급한 것처럼 $Var(X) = E(X^2) - E(X)^2$ 이고 $E(X)^2 = 25$ 이므로,  
 +\begin{align*} 
 +Var(X) & = E(X^2) - E(X)^2 \\ 
 +& = 45 - 25 \\ 
 +& = 20  
 +\end{align*} 
 + 
 +일반적으로  
 +\begin{align} 
 +Var(X) = \displaystyle \frac{q}{p^{2}} 
 +\end{align}
  
 +아래는 이를 R에서 계산해 본 것
 <code> <code>
 q/(p^2) q/(p^2)
Line 558: Line 613:
 </code> </code>
 ===== Sum up ===== ===== Sum up =====
-$$P(X = r) = p * q^{r-1} $$ +\begin{align} 
-$$P(X > r) = q^{r} $$ +P(X = r) = p * q^{r-1} \\ 
-$$P(X \le r) = 1 - q^{r} $$ +P(X > r) = q^{r} \\ 
-$$E(X) = \displaystyle \frac{1}{p}$$ +P(X \le r) = 1 - q^{r} \\  
-$$Var(X) = \displaystyle \frac{q}{p^{2}} $$ +E(X) = \displaystyle \frac{1}{p} \\ 
 +Var(X) = \displaystyle \frac{q}{p^{2}} \\  
 +\end{align} 
 +$(5)$, $(6)$에 대한 증명은 [[:Mean and Variance of Geometric Distribution]]
 ===== e.g., ===== ===== e.g., =====
 <WRAP box> <WRAP box>
Line 586: Line 643:
  
 ====== Binomial Distributions ====== ====== Binomial Distributions ======
 +
 +  - 1번의 시행에서 특정 사건 A가 발생할 확률을 p라고 하면 
 +  - n번의 (독립적인) 시행에서 사건 A가 발생할 때의 확률 분포를 
 +  - **이항확률분포**라고 한다.
 +
 {{:b:head_first_statistics:pasted:20191030-035316.png}} {{:b:head_first_statistics:pasted:20191030-035316.png}}
 {{:b:head_first_statistics:pasted:20191030-035452.png}} {{:b:head_first_statistics:pasted:20191030-035452.png}}
Line 596: Line 658:
 {{:b:head_first_statistics:pasted:20191030-040346.png}} {{:b:head_first_statistics:pasted:20191030-040346.png}}
  
-$$P(X = r) = \Huge\text{?} \cdot 0.25^{r} \cdot 0.75^{3-r}$$ +$$P(X = r) = {\huge\text{?} \cdot 0.25^{r} \cdot 0.75^{3-r}} $$ 
-$$P(X = r) = \displaytype _{3}C_{r} \cdot 0.25^{r} \cdot 0.75^{3-r}$$+$$P(X = r) = {\huge_{3}C_{r}} \cdot 0.25^{r} \cdot 0.75^{3-r}$$
  
 $_{n}C_{r}$은 n개의 사물에서 r개를 (순서없이) 고르는 방법의 수라고 할 때, 3개의 질문 중에서 한 개의 정답을 맞히는 방법은 $_{3}C_{1} = 3$ 세가지가 존재. $_{n}C_{r}$은 n개의 사물에서 r개를 (순서없이) 고르는 방법의 수라고 할 때, 3개의 질문 중에서 한 개의 정답을 맞히는 방법은 $_{3}C_{1} = 3$ 세가지가 존재.
Line 612: Line 674:
 \end{eqnarray*}  \end{eqnarray*} 
  
-$$P(X = r) = \displaytype _{n}C_{r} \cdot 0.25^{r} \cdot 0.75^{n-r}$$ +$$P(X = r) = _{n}C_{r} \cdot 0.25^{r} \cdot 0.75^{n-r}$$ 
-$$P(X = r) = \displaytype _{n}C_{r} \cdot p^{r} \cdot q^{n-r}$$+$$P(X = r) = _{n}C_{r} \cdot p^{r} \cdot q^{n-r}$$
  
   - You’re running a series of independent trials.   - You’re running a series of independent trials.
Line 622: Line 684:
  
 \begin{eqnarray*}  \begin{eqnarray*} 
-P(X = r) & = & \displaytype _{n}C_{r} \cdot p^{r} \cdot q^{n-r} \;\;\; \text{Where,} \\ +P(X = r) & = & _{n}C_{r} \cdot p^{r} \cdot q^{n-r} \;\;\; \text{Where,} \\ 
-_{n}C_{r} & = & \displaytype \frac {n!}{r!(n-r)!}+_{n}C_{r} & = & \frac {n!}{r!(n-r)!}
 \end{eqnarray*}  \end{eqnarray*} 
  
Line 804: Line 866:
  
 X = 0, 1 (failure and success) X = 0, 1 (failure and success)
-$P(X=x) = p^{x}(1-p)^{1-x}$+$P(X=x) = p^{x}(1-p)^{1-x}$ or  
 +$P(x) = p^{x}(1-p)^{1-x}$ 
 + 
 +참고. 
 +| x  | 0  | 1  | 
 +| p(x)  | q = (1-p)  | p  | 
  
 When x = 0 (failure), $P(X = 0) = p^{0}(1-p)^{1-0} = (1-p)$ = Probability of failure When x = 0 (failure), $P(X = 0) = p^{0}(1-p)^{1-0} = (1-p)$ = Probability of failure
Line 815: Line 882:
 </WRAP> </WRAP>
  
-$$P(X=x) = p^{x}(1-p)^{1-x}$$+$P(X=x) = p^{x}(1-p)^{1-x}$ or  
 +$P(x) = p^{x}(1-p)^{1-x}$
 X takes, x = 0, 1 X takes, x = 0, 1
  
 +==== Expectation and Variance value ====
 \begin{eqnarray*} \begin{eqnarray*}
-E(X) & = & \sum_{x}xp(X=x) \\+E(X) & = & \sum_{x}xP(x) \\
 & = & 0*p^{0}(1-p)^{1-0} + 1*p^{1}(1-p)^{1-1}  \\ & = & 0*p^{0}(1-p)^{1-0} + 1*p^{1}(1-p)^{1-1}  \\
-& = & p +& = & p \\ 
-\end{eqnarray*} +\\
- +
-\begin{eqnarray*}+
 Var(X) & = & E((X-\mu)^{2}) \\ Var(X) & = & E((X-\mu)^{2}) \\
-& = & \sum_{x}(x-\mu)^2p(x)  +& = & \sum_{x}(x-\mu)^2P(x) \\
 \end{eqnarray*} \end{eqnarray*}
- +그런데 
-한편,+
 \begin{eqnarray*} \begin{eqnarray*}
 E((X-\mu)^{2}) & = & E(X^2) - (E(X))^2 \\ E((X-\mu)^{2}) & = & E(X^2) - (E(X))^2 \\
Line 836: Line 902:
 위에서  위에서 
 \begin{eqnarray*} \begin{eqnarray*}
-E(X^{2}) & = & \sum X^2 p(x) \\+E(X^{2}) & = & \sum x^2 p(x) \\
 & = & 0^2*p^0(1-p)^{1-0} + 1^2*p^1(1-p)^{1-1} \\ & = & 0^2*p^0(1-p)^{1-0} + 1^2*p^1(1-p)^{1-1} \\
 & = & p & = & p
Line 852: Line 918:
 \end{eqnarray*} \end{eqnarray*}
  
-위는 First Head Statistics 에서 $X \sim (1, 0.25)$ 에서 E(X)와 Var(X)를 구한 후 (각각, p와 pq), X가 n가지가 있다고 확장하여 np와 npq를 구한 것과 같다. 즉, 교재는 Bernoulli distribution을 이야기(설명)하지 않고, 활용하여 binomial distribution의 기대값과 분산값을 구해낸 것이다. 아래는 그 나머지.+위는 First Head Statistics 에서 $X \sim (1, 0.25)$ 에서 E(X)와 Var(X)를 구한 후 (각각, p와 pq), X가 n가지가 있다고 확장하여 np와 npq를 구한 것과 같다. 즉, 교재는 Bernoulli distribution을 이야기(설명)하지 않고, 활용하여 binomial distribution의 기대값과 분산값을 구해낸 것이다. 
  
-==== Proof of E and Var ====+==== Proof of E and Var from Bernoulli Distribution ====
  
 $E(U_{i}) = p$  and $Var(U_{i}) = p(1-p)$ or $Var(U_{i}) = p \cdot q$ $E(U_{i}) = p$  and $Var(U_{i}) = p(1-p)$ or $Var(U_{i}) = p \cdot q$
Line 875: Line 941:
  
  
-==== From a scratch ==== +==== From a scratch (Proof of Binomial Expected Value) ==== 
-\begin{eqnarray*} +[[:Mean and Variance of Binomial Distribution|이항분포에서의 기댓값과 분산에 대한 수학적 증명]]Mathematical proof of Binomial Distribution Expected value and Variance
-(a + b)^{m} = \sum^{m}_{y=0}{{m}\choose{y}} a^{y} b^{m-y} \\ +
-\end{eqnarray*} +
- +
-See youtube video clip +
-{{youtube>8fqkQRjcR1M}}  +
-The Binomial Distribution: Mathematically Deriving the Mean and Variance +
 ====== Poisson Distribution ====== ====== Poisson Distribution ======
 $$X \sim Po(\lambda)$$ $$X \sim Po(\lambda)$$
Line 908: Line 967:
 For curiosity,  For curiosity, 
 \begin{eqnarray*} \begin{eqnarray*}
-\sum_{r=0}^{\infty} e^{- \lambda} \dfrac{\lambda^{r}} {r!} +\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} \left(1 + \lambda + \dfrac{\lambda^{2}}{2!} + \dfrac{\lambda^{3}}{3!} + . . . \right) \\
 & = & e^{- \lambda}e^{\lambda} \\ & = & e^{- \lambda}e^{\lambda} \\
 & = & 1 & = & 1
 \end{eqnarray*} \end{eqnarray*}
 +
 +왜 $e^{\lambda} = \left(1 + \lambda + \dfrac{\lambda^{2}}{2!} + \dfrac{\lambda^{3}}{3!} + . . . \right)$ 인지는 [[:Taylor series]] 문서를 참조.
  
 <code> <code>
Line 930: Line 992:
  
 \begin{eqnarray*} \begin{eqnarray*}
-P(X=r) = e^{- \lambda} \dfrac{\lambda^{r}} {r!},\qquad = 0, 1, 2, . . .,+P(X=r) = e^{- \lambda} \dfrac{\lambda^{r}} {r!},\qquad = 0, 1, 2, . . .,
 \end{eqnarray*} \end{eqnarray*}
  
Line 951: Line 1013:
 > plot(dpois(x=1:60, lambda=30), type = "l") > plot(dpois(x=1:60, lambda=30), type = "l")
 > </code> > </code>
 +
 +위에서 언급한 
 +
 +\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:1000, lambda=30)과 같은 케이스). 
 +
 +
 [{{:b:head_first_statistics:pasted:20191107-095627.png|Figure 1. lambda=30}}] [{{:b:head_first_statistics:pasted:20191107-095627.png|Figure 1. lambda=30}}]
  
Line 986: Line 1062:
  
 __1. What’s the probability of the machine not malfunctioning next week?__ __1. What’s the probability of the machine not malfunctioning next week?__
 +
 $\lambda = 3.4$ $\lambda = 3.4$
-$ malfunctioning = 0$+$\text{malfunctioning= 0$
  
 \begin{eqnarray*} \begin{eqnarray*}
-P(X=0) & = & \displaytype\frac{e^{-3.4}*3.4^{0}} {0!}  \\ +P(X=0) & = & \frac{e^{-3.4}*3.4^{0}} {0!}  \\ 
-& = & \displaytype e^{3.4} \\+& = & e^{-3.4} \\
 & = & 0.03337327  & = & 0.03337327 
 \end{eqnarray*} \end{eqnarray*}
Line 1006: Line 1083:
 x <- 3 x <- 3
 e <- exp(1) e <- exp(1)
-ans <- ((e^(-l))*l^x)/x!+ans <- ((e^(-l))*l^x)/factorial(x)
 </code> </code>
  
Line 1022: Line 1099:
 > dpois(x=3, lambda=3.4) > dpois(x=3, lambda=3.4)
 [1] 0.2186172 [1] 0.2186172
 +</code>
 +
 +마찬가지로 적어도 3번까지 고장나는 경우는 0, 1, 2, 3을 포함하므로 
 +<code>
 +> sum(dpois(c(0:3), lambda=3.4))
 +[1] 0.5583571
 +
 </code> </code>
  
Line 1031: Line 1115:
 \end{eqnarray*} \end{eqnarray*}
  
 +[[:mean and variance of Poisson distribution]]
 ===== Two Poisson distribution cases ===== ===== Two Poisson distribution cases =====
  
Line 1107: Line 1192:
 > a*b*c > a*b*c
 [1] 0.03268244 [1] 0.03268244
 +
 +</code>
 +위가 답이긴 하지만 limited calculator 로는 
 +x ~ b (n, p)이고
 +b(100, 0.1)이므로 
 +n*p = 10 = lambda 
 +따라서
 +<code>
 +> dpois(x=15, lambda=10)
 +[1] 0.03471807
  
 </code> </code>
b/head_first_statistics/geometric_binomial_and_poisson_distributions.1573089991.txt.gz · Last modified: 2019/11/07 10:26 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki