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 [2023/10/18 14:37] – [From a scratch (Proof of Binomial Expected Value)] hkimscilb:head_first_statistics:geometric_binomial_and_poisson_distributions [2025/10/15 08:31] (current) – [e.g.,] 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 27: Line 46:
  
 | X  | P(X=x)  | Power of 0.8  | Power of 0.2  | | X  | P(X=x)  | Power of 0.8  | Power of 0.2  |
-| 1  | 0.2  | 0  | 1  | +| 1  | 0.8<sup>0</sup>0.2   | 0  | 1  | 
-| 2  | 0.8 * 0.2   | 1  | 1  |+| 2  | 0.8<sup>1</sup> * 0.2   | 1  | 1  |
 | 3  | 0.8<sup>2</sup> * 0.2   | 2  | 1  | | 3  | 0.8<sup>2</sup> * 0.2   | 2  | 1  |
 | 4  | 0.8<sup>3</sup> * 0.2   | 3  | 1  | | 4  | 0.8<sup>3</sup> * 0.2   | 3  | 1  |
Line 39: Line 58:
 This formula is called the **geometric distribution**. This formula is called the **geometric distribution**.
    
-  You run a series of independent trials.  +  You run a series of independent trials.   * (각 시행이 독립적임 = 이번 시행이 이전 시행과 상관없이 일어남) 
-  There can be either a success or failure for each trial, and the probability of success is the same for each trial. +  There can be either a success or failure for each trial, and the probability of success is the same for each trial. (성공/실패만 일어나는 상황에서, 성공하는 확률은 p로 실행햇수동안 일정) 
-  The main thing you’re interested in is how many trials are needed in +  The main thing you’re interested in is how many trials are needed in order to get the first successful outcome. (성공하면 중단하고 성공할 때까지의 확률을 분포로 봄)
-order to get the first successful outcome.+
  
 $ P(X=r) = {p \cdot q^{r-1}} $ $ P(X=r) = {p \cdot q^{r-1}} $
Line 55: Line 73:
 ## rather than p * q^(r-1) ## rather than p * q^(r-1)
 dgeom(x = 0:n, prob = p) dgeom(x = 0:n, prob = p)
-hist(dgeom(x = 0:n, prob = p))+hist(dgeom(x = 0:n, prob = p)) 
 +barplot(dgeom(x=0:n, p))
 </code> </code>
  
Line 69: Line 88:
 [29] 0.0003868563 0.0003094850  [29] 0.0003868563 0.0003094850 
  
-> hist(dgeom(x = 0:n, prob = p))+hist(dgeom(x = 0:n, prob = p)) 
 +> barplot(dgeom(x=0:n, p))
 </code> </code>
  
-{{:b:head_first_statistics:pasted:20191030-023820.png}} +<code> {{:b:head_first_statistics:pasted:20191030-023820.png}} </code> 
- +{{:b:head_first_statistics:pasted:20251013-080224.png}} 
-r번 시도한 다음에 성공을 얻을 확률 +r번 시도한 이후, 그 이후 어디서든지 간에 성공을 얻을 확률
-첫 번째 성공을 얻을 때까지 r번 이상 시도를 해야하는 확률+
 $$ P(X > r) = q^{r} $$ $$ P(X > r) = q^{r} $$
  
-20번 시도 후에 어디선가 성공할 확률은? +예, 20번 시도 후에 어디선가 성공할 확률은? 
  
 Solution.  Solution. 
Line 84: Line 103:
   * 위는 구할 수 없음   * 위는 구할 수 없음
   * 따라서   * 따라서
 +  * 전체 확률이 1이고 20번째까지 성공한 확률을 1에서 빼면 원하는 확률이 됨
   * 1 - (1번째 성공 + 2번째 성공 + . . . + 20번째 성공)   * 1 - (1번째 성공 + 2번째 성공 + . . . + 20번째 성공)
   * 그런데 이것은    * 그런데 이것은 
Line 92: Line 112:
 n <- 19 n <- 19
 s <- dgeom(x = 0:n, prob = p) s <- dgeom(x = 0:n, prob = p)
-# 20번째까지 성공할 확률+# 20번째까지 성공할 확률을 모두 더한 확률
 sum(s) sum(s)
-# 따라서 아래는 20번 이후에 성공할 확률+# 따라서 아래는 20번 이후 어디서든지 간서 성공할 확률
 1-sum(s) 1-sum(s)
 ## 혹은 (교재가 이야기하는) 20번까지 실패하는 확률 ## 혹은 (교재가 이야기하는) 20번까지 실패하는 확률
Line 108: Line 128:
 > sum(s) > sum(s)
 [1] 0.9884708 [1] 0.9884708
-> # 따라서 아래는 20번 이후에 성공할 확률+> # 따라서 아래는 20번 이후 어디서든지 간서 성공할 확률
 > 1-sum(s) > 1-sum(s)
 [1] 0.01152922 [1] 0.01152922
Line 151: Line 171:
 |     | x번째 (trial번째) \\ 성공할 확률  | x번째의 기대치 \\ (주사위 경우처럼)  | 그 x번째까지 성공할 \\ 확률에 대한 기대값  | |     | x번째 (trial번째) \\ 성공할 확률  | x번째의 기대치 \\ (주사위 경우처럼)  | 그 x번째까지 성공할 \\ 확률에 대한 기대값  |
  
 +  * 우리가 작업하고 있는 채드의 슬로프 타기 예가 얼른 이해가 안된다면 아래 workout의 예를 들어 본다. 
  
 +^ x  ^ p(x) px ^ npx.0        npx = weighted \\ probability at \\ a given spot  ^ plex.0  ^  plex  ^   ^
 +| 0  | 0.1     | 0 * 0.1   | 0.00   | 0.00  | 0.00  |   |
 +| 1  | 0.15    | 1 * 0.15  | 0.15   | 0.00 + 0.15 | 0.15  |   |
 +| 2  | 0.4     | 2 * 0.4   | 0.80   | 0.00 + 0.15 + 0.80  | 0.95  |   |
 +| 3  | 0.25    | 3 * 0.25  | 0.75   | 0.00 + 0.15 + 0.80 + 0.75  | 1.7  |   |
 +| 4  | 0.1     | 4 * 0.1   | 0.40   | 0.00 + 0.15 + 0.80 + 0.75 + 0.40  | 2.1  | = this is E(x)  |
 +
 +  * x 일주일에 내가 갈 운동횟수 (workout frequency, 0 to 4) 
 +  * px 각 횟수에 대한 probability 
 +  * npx weighted probability 
 +  * plex cumulative sum of npx (to find out the below last one)
 +  * sum of npx = 2.1 = mean of all = expected value of x = E(x)
 +  * https://www.youtube.com/watch?v=qafPcWNUiM8 참조
  
 <code> <code>
Line 197: Line 231:
  
 </code> </code>
 +
 +  * 아래의 예는 위의 workout 예처럼 횟수가 0-4로 정해져 있지 않고 계속 진행됨 (0-무한대)
 +  * 하지만 여기서는 100 까지로 한정 (1:100)
 +  * 각 지점에서의 probability = geometric probability = q^(trial-1)*p = px
 +  * 각 지점에서의 weighted prob = trial * px = npx 
 +  * 각 단계에서의 기대값을 구하기 위한 누적합계 cumsum(npx) = plex
 +  * 아래 그림에서 plex는 각 단계의 probability density를 더해온 값을 말한다. 
 +  * 그림이 암시하는 것처럼 오른 쪽으로 한 없이 가면서 생기는 그래프의 용적은 기대값이 된다.
 +
 +| {{:b:head_first_statistics:pasted:20251002-072502.png?400}} | 
 +| {{:b:head_first_statistics:pasted:20251002-072514.png?400}} | 
 +| {{:b:head_first_statistics:pasted:20251002-072522.png?400}} | 
  
 <code> <code>
 +p <- .2
 +q <- 1-p
 +trial <- c(1:100)
 +px <- q^(trial-1)*p
 +px
 +npx <- trial*px
 +npx
 +## plex <- cumsum(trial*(q^(trial-1))*p)
 +## 위는 아래와 같음
 +plex <- cumsum(npx)
 +plex
 +sumgeod <- data.frame(trial,px,npx,plex)
 +sumgeod 
 +
 +plot(npx, type="l")
 +plot(plex, type="l")
 +</code>
 +
 +<code>
 +
 > p <- .2 > p <- .2
 > q <- 1-p > q <- 1-p
 > trial <- c(1:100) > trial <- c(1:100)
 > px <- q^(trial-1)*p > px <- q^(trial-1)*p
-round(px, 3) +> px 
-  [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 +  [1] 2.000000e-01 1.600000e-01 1.280000e-01 1.024000e-01 
- [13] 0.014 0.011 0.009 0.007 0.006 0.005 0.004 0.003 0.002 0.002 0.001 0.001 +  [5] 8.192000e-02 6.553600e-02 5.242880e-02 4.194304e-02 
- [25] 0.001 0.001 0.001 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +  [9] 3.355443e-02 2.684355e-02 2.147484e-02 1.717987e-02 
- [37] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 + [13] 1.374390e-02 1.099512e-02 8.796093e-03 7.036874e-03 
- [49] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 + [17] 5.629500e-03 4.503600e-03 3.602880e-03 2.882304e-03 
- [61] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 + [21] 2.305843e-03 1.844674e-03 1.475740e-03 1.180592e-03 
- [73] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 + [25] 9.444733e-04 7.555786e-04 6.044629e-04 4.835703e-04 
- [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 + [29] 3.868563e-04 3.094850e-04 2.475880e-04 1.980704e-04 
- [97] 0.000 0.000 0.000 0.000 + [33] 1.584563e-04 1.267651e-04 1.014120e-04 8.112964e-05 
-> npx <- trial*(q^(trial-1))*p + [37] 6.490371e-05 5.192297e-05 4.153837e-05 3.323070e-05 
-round(npx, 3) + [41] 2.658456e-05 2.126765e-05 1.701412e-05 1.361129e-05 
-  [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 + [45] 1.088904e-05 8.711229e-06 6.968983e-06 5.575186e-06 
- [13] 0.179 0.154 0.132 0.113 0.096 0.081 0.068 0.058 0.048 0.041 0.034 0.028 + [49] 4.460149e-06 3.568119e-06 2.854495e-06 2.283596e-06 
- [25] 0.024 0.020 0.016 0.014 0.011 0.009 0.008 0.006 0.005 0.004 0.004 0.003 + [53] 1.826877e-06 1.461502e-06 1.169201e-06 9.353610e-07 
- [37] 0.002 0.002 0.002 0.001 0.001 0.001 0.001 0.001 0.000 0.000 0.000 0.000 + [57] 7.482888e-07 5.986311e-07 4.789049e-07 3.831239e-07 
- [49] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 + [61] 3.064991e-07 2.451993e-07 1.961594e-07 1.569275e-07 
- [61] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 + [65] 1.255420e-07 1.004336e-07 8.034690e-08 6.427752e-08 
- [73] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 + [69] 5.142202e-08 4.113761e-08 3.291009e-08 2.632807e-08 
- [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 + [73] 2.106246e-08 1.684997e-08 1.347997e-08 1.078398e-08 
- [97] 0.000 0.000 0.000 0.000 + [77] 8.627183e-09 6.901746e-09 5.521397e-09 4.417118e-09 
-> plex <- cumsum(trial*(q^(trial-1))*p) + [81] 3.533694e-09 2.826955e-09 2.261564e-09 1.809251e-09 
-round(plex, 3+ [85] 1.447401e-09 1.157921e-09 9.263367e-10 7.410694e-10 
-  [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 + [89] 5.928555e-10 4.742844e-10 3.794275e-10 3.035420e-10 
- [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 + [93] 2.428336e-10 1.942669e-10 1.554135e-10 1.243308e-10 
- [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 + [97] 9.946465e-11 7.957172e-11 6.365737e-11 5.092590e-11 
- [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 +> npx <- trial*px 
- [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 +> npx 
- [615.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 +  [1] 2.000000e-01 3.200000e-01 3.840000e-01 4.096000e-01 
- [735.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 +  [5] 4.096000e-01 3.932160e-01 3.670016e-01 3.355443e-01 
- [85] 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 5.000 +  [9] 3.019899e-01 2.684355e-01 2.362232e-01 2.061584e-01 
- [975.000 5.000 5.000 5.000+ [13] 1.786706e-01 1.539316e-01 1.319414e-01 1.125900e-01 
 + [17] 9.570149e-02 8.106479e-02 6.845471e-02 5.764608e-02 
 + [21] 4.842270e-02 4.058284e-02 3.394201e-02 2.833420e-02 
 + [25] 2.361183e-02 1.964504e-02 1.632050e-02 1.353997e-02 
 + [29] 1.121883e-02 9.284550e-03 7.675228e-03 6.338253e-03 
 + [33] 5.229059e-03 4.310012e-03 3.549422e-03 2.920667e-03 
 + [37] 2.401437e-03 1.973073e-03 1.619997e-03 1.329228e-03 
 + [41] 1.089967e-03 8.932412e-04 7.316071e-04 5.988970e-04 
 + [45] 4.900066e-04 4.007165e-04 3.275422e-04 2.676089e-04 
 + [49] 2.185473e-04 1.784060e-04 1.455793e-04 1.187470e-04 
 + [53] 9.682448e-05 7.892109e-05 6.430607e-05 5.238022e-05 
 + [57] 4.265246e-05 3.472060e-05 2.825539e-05 2.298743e-05 
 + [61] 1.869645e-05 1.520236e-05 1.235804e-05 1.004336e-05 
 + [65] 8.160232e-06 6.628619e-06 5.383242e-06 4.370871e-06 
 + [69] 3.548119e-06 2.879633e-06 2.336616e-06 1.895621e-06 
 + [73] 1.537559e-06 1.246898e-06 1.010998e-06 8.195824e-07 
 + [77] 6.642931e-07 5.383362e-07 4.361904e-07 3.533694e-07 
 + [81] 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 
 + [89] 5.276414e-08 4.268560e-08 3.452790e-08 2.792587e-08 
 + [93] 2.258353e-08 1.826109e-08 1.476428e-08 1.193576e-08 
 + [97] 9.648071e-09 7.798028e-09 6.302080e-09 5.092590e-09 
 +## plex <- cumsum(trial*(q^(trial-1))*p) 
 +## 위는 아래와 같음 
 +plex <- cumsum(npx) 
 +> plex 
 +  [1] 0.200000 0.520000 0.904000 1.313600 1.723200 2.116416 2.483418 
 +  [8] 2.818962 3.120952 3.389387 3.625610 3.831769 4.010440 4.164371 
 + [15] 4.296313 4.408903 4.504604 4.585669 4.654124 4.711770 4.760192 
 + [22] 4.800775 4.834717 4.863051 4.886663 4.906308 4.922629 4.936169 
 + [29] 4.947388 4.956672 4.964347 4.970686 4.975915 4.980225 4.983774 
 + [36] 4.986695 4.989096 4.991069 4.992689 4.994018 4.995108 4.996002 
 + [43] 4.996733 4.997332 4.997822 4.998223 4.998550 4.998818 4.999037 
 + [50] 4.999215 4.999361 4.999479 4.999576 4.999655 4.999719 4.999772 
 + [57] 4.999814 4.999849 4.999877 4.999900 4.999919 4.999934 4.999947 
 + [644.999957 4.999965 4.999971 4.999977 4.999981 4.999985 4.999988 
 + [71] 4.999990 4.999992 4.999993 4.999995 4.999996 4.999997 4.999997 
 + [784.999998 4.999998 4.999998 4.999999 4.999999 4.999999 4.999999 
 + [85] 4.999999 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 
 + [92] 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 
 + [99] 5.000000 5.000000
 > sumgeod <- data.frame(trial,px,npx,plex) > sumgeod <- data.frame(trial,px,npx,plex)
-round(sumgeod,3) +> sumgeod  
-    trial    px   npx  plex +    trial           px          npx     plex 
-1       0.200 0.200 0.200 +1       2.000000e-01 2.000000e-01 0.200000 
-2       0.160 0.320 0.520 +2       1.600000e-01 3.200000e-01 0.520000 
-3       0.128 0.384 0.904 +3       1.280000e-01 3.840000e-01 0.904000 
-4       0.102 0.410 1.314 +4       1.024000e-01 4.096000e-01 1.313600 
-5       0.082 0.410 1.723 +5       8.192000e-02 4.096000e-01 1.723200 
-6       0.066 0.393 2.116 +6       6.553600e-02 3.932160e-01 2.116416 
-7       0.052 0.367 2.483 +7       5.242880e-02 3.670016e-01 2.483418 
-8       0.042 0.336 2.819 +8       4.194304e-02 3.355443e-01 2.818962 
-9       0.034 0.302 3.121 +9       3.355443e-02 3.019899e-01 3.120952 
-10     10 0.027 0.268 3.389 +10     10 2.684355e-02 2.684355e-01 3.389387 
-11     11 0.021 0.236 3.626 +11     11 2.147484e-02 2.362232e-01 3.625610 
-12     12 0.017 0.206 3.832 +12     12 1.717987e-02 2.061584e-01 3.831769 
-13     13 0.014 0.179 4.010 +13     13 1.374390e-02 1.786706e-01 4.010440 
-14     14 0.011 0.154 4.164 +14     14 1.099512e-02 1.539316e-01 4.164371 
-15     15 0.009 0.132 4.296 +15     15 8.796093e-03 1.319414e-01 4.296313 
-16     16 0.007 0.113 4.409 +16     16 7.036874e-03 1.125900e-01 4.408903 
-17     17 0.006 0.096 4.505 +17     17 5.629500e-03 9.570149e-02 4.504604 
-18     18 0.005 0.081 4.586 +18     18 4.503600e-03 8.106479e-02 4.585669 
-19     19 0.004 0.068 4.654 +19     19 3.602880e-03 6.845471e-02 4.654124 
-20     20 0.003 0.058 4.712 +20     20 2.882304e-03 5.764608e-02 4.711770 
-21     21 0.002 0.048 4.760 +21     21 2.305843e-03 4.842270e-02 4.760192 
-22     22 0.002 0.041 4.801 +22     22 1.844674e-03 4.058284e-02 4.800775 
-23     23 0.001 0.034 4.835 +23     23 1.475740e-03 3.394201e-02 4.834717 
-24     24 0.001 0.028 4.863 +24     24 1.180592e-03 2.833420e-02 4.863051 
-25     25 0.001 0.024 4.887 +25     25 9.444733e-04 2.361183e-02 4.886663 
-26     26 0.001 0.020 4.906 +26     26 7.555786e-04 1.964504e-02 4.906308 
-27     27 0.001 0.016 4.923 +27     27 6.044629e-04 1.632050e-02 4.922629 
-28     28 0.000 0.014 4.936 +28     28 4.835703e-04 1.353997e-02 4.936169 
-29     29 0.000 0.011 4.947 +29     29 3.868563e-04 1.121883e-02 4.947388 
-30     30 0.000 0.009 4.957 +30     30 3.094850e-04 9.284550e-03 4.956672 
-31     31 0.000 0.008 4.964 +31     31 2.475880e-04 7.675228e-03 4.964347 
-32     32 0.000 0.006 4.971 +32     32 1.980704e-04 6.338253e-03 4.970686 
-33     33 0.000 0.005 4.976 +33     33 1.584563e-04 5.229059e-03 4.975915 
-34     34 0.000 0.004 4.980 +34     34 1.267651e-04 4.310012e-03 4.980225 
-35     35 0.000 0.004 4.984 +35     35 1.014120e-04 3.549422e-03 4.983774 
-36     36 0.000 0.003 4.987 +36     36 8.112964e-05 2.920667e-03 4.986695 
-37     37 0.000 0.002 4.989 +37     37 6.490371e-05 2.401437e-03 4.989096 
-38     38 0.000 0.002 4.991 +38     38 5.192297e-05 1.973073e-03 4.991069 
-39     39 0.000 0.002 4.993 +39     39 4.153837e-05 1.619997e-03 4.992689 
-40     40 0.000 0.001 4.994 +40     40 3.323070e-05 1.329228e-03 4.994018 
-41     41 0.000 0.001 4.995 +41     41 2.658456e-05 1.089967e-03 4.995108 
-42     42 0.000 0.001 4.996 +42     42 2.126765e-05 8.932412e-04 4.996002 
-43     43 0.000 0.001 4.997 +43     43 1.701412e-05 7.316071e-04 4.996733 
-44     44 0.000 0.001 4.997 +44     44 1.361129e-05 5.988970e-04 4.997332 
-45     45 0.000 0.000 4.998 +45     45 1.088904e-05 4.900066e-04 4.997822 
-46     46 0.000 0.000 4.998 +46     46 8.711229e-06 4.007165e-04 4.998223 
-47     47 0.000 0.000 4.999 +47     47 6.968983e-06 3.275422e-04 4.998550 
-48     48 0.000 0.000 4.999 +48     48 5.575186e-06 2.676089e-04 4.998818 
-49     49 0.000 0.000 4.999 +49     49 4.460149e-06 2.185473e-04 4.999037 
-50     50 0.000 0.000 4.999 +50     50 3.568119e-06 1.784060e-04 4.999215 
-51     51 0.000 0.000 4.999 +51     51 2.854495e-06 1.455793e-04 4.999361 
-52     52 0.000 0.000 4.999 +52     52 2.283596e-06 1.187470e-04 4.999479 
-53     53 0.000 0.000 5.000 +53     53 1.826877e-06 9.682448e-05 4.999576 
-54     54 0.000 0.000 5.000 +54     54 1.461502e-06 7.892109e-05 4.999655 
-55     55 0.000 0.000 5.000 +55     55 1.169201e-06 6.430607e-05 4.999719 
-56     56 0.000 0.000 5.000 +56     56 9.353610e-07 5.238022e-05 4.999772 
-57     57 0.000 0.000 5.000 +57     57 7.482888e-07 4.265246e-05 4.999814 
-58     58 0.000 0.000 5.000 +58     58 5.986311e-07 3.472060e-05 4.999849 
-59     59 0.000 0.000 5.000 +59     59 4.789049e-07 2.825539e-05 4.999877 
-60     60 0.000 0.000 5.000 +60     60 3.831239e-07 2.298743e-05 4.999900 
-61     61 0.000 0.000 5.000 +61     61 3.064991e-07 1.869645e-05 4.999919 
-62     62 0.000 0.000 5.000 +62     62 2.451993e-07 1.520236e-05 4.999934 
-63     63 0.000 0.000 5.000 +63     63 1.961594e-07 1.235804e-05 4.999947 
-64     64 0.000 0.000 5.000 +64     64 1.569275e-07 1.004336e-05 4.999957 
-65     65 0.000 0.000 5.000 +65     65 1.255420e-07 8.160232e-06 4.999965 
-66     66 0.000 0.000 5.000 +66     66 1.004336e-07 6.628619e-06 4.999971 
-67     67 0.000 0.000 5.000 +67     67 8.034690e-08 5.383242e-06 4.999977 
-68     68 0.000 0.000 5.000 +68     68 6.427752e-08 4.370871e-06 4.999981 
-69     69 0.000 0.000 5.000 +69     69 5.142202e-08 3.548119e-06 4.999985 
-70     70 0.000 0.000 5.000 +70     70 4.113761e-08 2.879633e-06 4.999988 
-71     71 0.000 0.000 5.000 +71     71 3.291009e-08 2.336616e-06 4.999990 
-72     72 0.000 0.000 5.000 +72     72 2.632807e-08 1.895621e-06 4.999992 
-73     73 0.000 0.000 5.000 +73     73 2.106246e-08 1.537559e-06 4.999993 
-74     74 0.000 0.000 5.000 +74     74 1.684997e-08 1.246898e-06 4.999995 
-75     75 0.000 0.000 5.000 +75     75 1.347997e-08 1.010998e-06 4.999996 
-76     76 0.000 0.000 5.000 +76     76 1.078398e-08 8.195824e-07 4.999997 
-77     77 0.000 0.000 5.000 +77     77 8.627183e-09 6.642931e-07 4.999997 
-78     78 0.000 0.000 5.000 +78     78 6.901746e-09 5.383362e-07 4.999998 
-79     79 0.000 0.000 5.000 +79     79 5.521397e-09 4.361904e-07 4.999998 
-80     80 0.000 0.000 5.000 +80     80 4.417118e-09 3.533694e-07 4.999998 
-81     81 0.000 0.000 5.000 +81     81 3.533694e-09 2.862292e-07 4.999999 
-82     82 0.000 0.000 5.000 +82     82 2.826955e-09 2.318103e-07 4.999999 
-83     83 0.000 0.000 5.000 +83     83 2.261564e-09 1.877098e-07 4.999999 
-84     84 0.000 0.000 5.000 +84     84 1.809251e-09 1.519771e-07 4.999999 
-85     85 0.000 0.000 5.000 +85     85 1.447401e-09 1.230291e-07 4.999999 
-86     86 0.000 0.000 5.000 +86     86 1.157921e-09 9.958120e-08 5.000000 ###########  
-87     87 0.000 0.000 5.000 +87     87 9.263367e-10 8.059129e-08 5.000000 
-88     88 0.000 0.000 5.000 +88     88 7.410694e-10 6.521410e-08 5.000000 
-89     89 0.000 0.000 5.000 +89     89 5.928555e-10 5.276414e-08 5.000000 
-90     90 0.000 0.000 5.000 +90     90 4.742844e-10 4.268560e-08 5.000000 
-91     91 0.000 0.000 5.000 +91     91 3.794275e-10 3.452790e-08 5.000000 
-92     92 0.000 0.000 5.000 +92     92 3.035420e-10 2.792587e-08 5.000000 
-93     93 0.000 0.000 5.000 +93     93 2.428336e-10 2.258353e-08 5.000000 
-94     94 0.000 0.000 5.000 +94     94 1.942669e-10 1.826109e-08 5.000000 
-95     95 0.000 0.000 5.000 +95     95 1.554135e-10 1.476428e-08 5.000000 
-96     96 0.000 0.000 5.000 +96     96 1.243308e-10 1.193576e-08 5.000000 
-97     97 0.000 0.000 5.000 +97     97 9.946465e-11 9.648071e-09 5.000000 
-98     98 0.000 0.000 5.000 +98     98 7.957172e-11 7.798028e-09 5.000000 
-99     99 0.000 0.000 5.000 +99     99 6.365737e-11 6.302080e-09 5.000000 
-100   100 0.000 0.000 5.000+100   100 5.092590e-11 5.092590e-09 5.000000
 > plot(npx, type="l") > plot(npx, type="l")
 > plot(plex, type="l") > plot(plex, type="l")
 </code> </code>
 +
 +  * 기댓값이 86번째 부터는 더이상 늘지 않고 
 +  * 계산된 값을 보면 5로 수렴한다.
 +  * workout 예처럼 다섯가지의 순서가 있는 것이 아니라서 
 +  * 평균을 어떻게 나오나 보기 위해서 100까지 해 봤지만 
 +  * 86번째 이후에는 평균값이 더 늘지 않는다 (5에서)
 +  * 따라서 위의 geometric distribution에서의 기대값은 5이다.
 +
 {{: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}$ 임을 알 수 있다. 아래는 그 증명이다.+ 
 +  * 그런데 이 기대값은 아래처럼 구할 수 있다.  
 +  * 위에서 $X \sim \text{Geo}(p)$ 일때, 기대값은 $E(X) = \dfrac{1}{p}$  
 +  * 아래는 그 증명이다.
  
 ===== Proof ===== ===== Proof =====
Line 584: Line 701:
  
 일반적으로  일반적으로 
-\begin{align}+\begin{eqnarray*}
 Var(X) = \displaystyle \frac{q}{p^{2}} Var(X) = \displaystyle \frac{q}{p^{2}}
-\end{align}+\end{eqnarray*}
  
 아래는 이를 R에서 계산해 본 것 아래는 이를 R에서 계산해 본 것
Line 602: Line 719:
 Var(X) & = \displaystyle \frac{q}{p^{2}} \\  Var(X) & = \displaystyle \frac{q}{p^{2}} \\ 
 \end{align} \end{align}
-$(5)$, $(6)$에 대한 증명은 [[:Mean and Variance of Geometric Distribution]]+ 
 +===== Proof of mean and variance of geometric distribution ===== 
 +$(4)$, $(5)$에 대한 증명은 [[:Mean and Variance of Geometric Distribution]]
 ===== e.g., ===== ===== e.g., =====
 <WRAP box> <WRAP box>
Line 620: Line 739:
 $Var(X) = \displaystyle \frac{q}{p^{2}}$ $Var(X) = \displaystyle \frac{q}{p^{2}}$
  
 +<code> 
 +> p <- .4 
 +> q <- 1-p 
 +>  
 +> p*q^(2-1) 
 +[1] 0.24 
 +> dgeom(1, p) 
 +[1] 0.24 
 +
 +> 1-q^4 
 +[1] 0.8704 
 +> dgeom(0:3, p) 
 +[1] 0.4000 0.2400 0.1440 0.0864 
 +> sum(dgeom(0:3, p)) 
 +[1] 0.8704 
 +> pgeom(3, p) 
 +[1] 0.8704 
 +
 +> q^4 
 +[1] 0.1296 
 +> 1-sum(dgeom(0:3, p)) 
 +[1] 0.1296 
 +> 1-pgeom(3, p) 
 +[1] 0.1296 
 +> pgeom(3, p, lower.tail = F) 
 +[1] 0.1296 
 +>  
 +> 1/p 
 +[1] 2.5 
 +
 +> q/p^2 
 +[1] 3.75 
 +>  
 +</code>
  
  
Line 629: Line 781:
   - n번의 (독립적인) 시행에서 사건 A가 발생할 때의 확률 분포를    - n번의 (독립적인) 시행에서 사건 A가 발생할 때의 확률 분포를 
   - **이항확률분포**라고 한다.   - **이항확률분포**라고 한다.
 +아래를 보면
 +  * 각 한문제를 맞힐 확률은 1/4, 틀릴 확률은 3/4
 +  * 3문제를 풀면서 (3번의 시행) 각 문제를 맞힐 확률 분포를 말한다. 
  
 {{:b:head_first_statistics:pasted:20191030-035316.png}} {{:b:head_first_statistics:pasted:20191030-035316.png}}
Line 659: Line 814:
 $$P(X = r) = _{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. (n번의 시행을 하게 된다) 
-  - There can be either a success or failure for each trial, and the probability of success is the same for each trial. +  - There can be either a success or failure for each trial, and the probability of success is the same for each trial. (각 시행은 성공/실패로 구분되고 성공의 확률은 (반대로 실패의 확률도) 각 시행마다 동일하다) 
-  - There are a finite number of trials. (note that this is different from that of geometric distribution)+  - There are a finite number of trials. Note that this is different from that of geometric distribution. (n번의 시행으로 한정된다. 무한대 시행이 아님)
  
 X가 n번의 시행에서 성공적인 결과를 얻는 수를 나타낸다고 할 때, r번의 성공이 있을 확률을 구하려면 아래 공식을 이용한다. X가 n번의 시행에서 성공적인 결과를 얻는 수를 나타낸다고 할 때, r번의 성공이 있을 확률을 구하려면 아래 공식을 이용한다.
Line 667: Line 822:
 \begin{eqnarray*}  \begin{eqnarray*} 
 P(X = r) & = & _{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} & = & \frac {n!}{r!(n-r)!}+\displaystyle _{n}C_{r} & = & \displaystyle \dfrac {n!}{r!(n-r)!} \\ 
 +\text{c.f.,  } \\ 
 +\displaystyle _{n} P_{r} & = & \displaystyle \dfrac {n!} {(n-r)!} \\
 \end{eqnarray*}  \end{eqnarray*} 
 +
 +see [[:b:head_first_statistics:permutation_and_combination#what_if_horse_order_doesn_t_matter|Permutation chapter]]
 +
  
 p = 각 시행에서 성공할 확률 p = 각 시행에서 성공할 확률
Line 677: Line 837:
  
 ===== Expectation and Variance of ===== ===== Expectation and Variance of =====
 +Toss a fair coin once. What is the distribution of the number of heads?
 +  * A single trial
 +  * The trial can be one of two possible outcomes -- success and failure
 +  * P(success) = p
 +  * P(failure) = 1-p
 +
 +X = 0, 1 (failure and success)
 +$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 = 1 (success), $P(X = 1) = p^{1}(1-p)^{0} = p $ = Probability of success
 +
  
-{{:b:head_first_statistics:pasted:20191104-013651.png}}+This is called Bernoulli distribution. 
 +  * Bernoulli distribution expands to binomial distribution, geometric distribution, etc. 
 +  * Binomial distribution = The distribution of number of success in n independent Bernoulli trials. 
 +  * Geometric distribution = The distribution of number of trials to get the first success in independent Bernoulli trials.
  
 $$X \sim B(1,p)$$ $$X \sim B(1,p)$$
  
 \begin{eqnarray*} \begin{eqnarray*}
-E(X) & = & \sum{n*p(x)} \\ +E(X) & = & \sum{* p(x)} \\ 
-& = & (1*p)+(0*q) \\+& = & (0*q) + (1*p) \\
 & = & p  & = & p 
 \end{eqnarray*}  \end{eqnarray*} 
Line 735: Line 915:
 n <-5 n <-5
 # combinations of 5,2 # combinations of 5,2
-c <- choose(5,2)+c <- choose(n,r
 ans1 <- c*(p^r)*(q^(n-r)) ans1 <- c*(p^r)*(q^(n-r))
-ans1+ans1    # or 
 + 
 +choose(n, r)*(p^r)*(q^(n-r)) 
 + 
 +dbinom(r, n, p) 
 +# dbinom(2, 5, 1/4) 
 </code> </code>
 +
 <code> <code>
 > p <- .25 > p <- .25
Line 745: Line 932:
 > n <-5 > n <-5
 > # combinations of 5,2 > # combinations of 5,2
-> c <- choose(5,2)+> c <- choose(n,r)
 > ans <- c*(p^r)*(q^(n-r)) > ans <- c*(p^r)*(q^(n-r))
 > ans > ans
 +[1] 0.2636719
 +>
 +> choose(n, r)*(p^r)*(q^(n-r))
 +[1] 0.2636719
 +>
 +> dbinom(r, n, p)
 [1] 0.2636719 [1] 0.2636719
  
Line 760: Line 953:
 n <-5 n <-5
 # combinations of 5,3 # combinations of 5,3
-c <- choose(5,3)+c <- choose(n,r)
 ans2 <- c*(p^r)*(q^(n-r)) ans2 <- c*(p^r)*(q^(n-r))
 ans2 ans2
 +
 +choose(n, r)*(p^r)*(q^(n-r))
 +
 +dbinom(r, n, p)
 +
 </code> </code>
 <code> <code>
Line 770: Line 968:
 > n <-5 > n <-5
 > # combinations of 5,3 > # combinations of 5,3
-> c <- choose(5,3)+> c <- choose(n,r)
 > ans2 <- c*(p^r)*(q^(n-r)) > ans2 <- c*(p^r)*(q^(n-r))
 > ans2 > ans2
 [1] 0.08789062 [1] 0.08789062
 +
 +> choose(n,r)*(p^r)*(q^(n-r))
 +[1] 0.08789062
 +
 +> dbinom(r, n, p)
 +[1] 0.08789063
 +
  
 </code> </code>
  
-Ans 3. +Ans 3. 중요 
 <code> <code>
-ans1 + ans2 +ans1 + ans2 
 +dbinom(2, 5, .25) + dbinom(3, 5, .25)  
 +dbinom(2:3, 5, .25) 
 +sum(dbinom(2:3, 5, .25)) 
 +pbinom(3, 5, .25) - pbinom(1, 5, .25)
 </code> </code>
  
-<code>> ans1 + ans2 +<code> 
 +> ans1 + ans2
 [1] 0.3515625 [1] 0.3515625
 +> dbinom(2, 5, .25) + dbinom(3, 5, .25) 
 +[1] 0.3515625
 +> dbinom(2:3, 5, .25)
 +[1] 0.26367187 0.08789063
 +> sum(dbinom(2:3, 5, .25))
 +[1] 0.3515625
 +> pbinom(3, 5, .25) - pbinom(1, 5, .25)
 +[1] 0.3515625
 +
 </code> </code>
  
Line 839: Line 1058:
 > </code> > </code>
  
-===== Another way to see E(Xand Var(X===== +Q. 한 문제를 맞힐 확률은 1/4 이다. 총 여섯 문제가 있다고 할 때, 0에서 5 문제를 맞힐 확률은? dbinom을 이용해서 구하시오. 
-==== Bernoulli Distribution ==== +<code> 
-Toss a fair coin once. What is the distribution of the number of heads? +p <- 1/4 
-  * A single trial +q <- 1-p 
-  * The trial can be one of two possible outcomes -- success and failure +n <- 6 
-  * P(success) = +pbinom(5, n, p) 
-  * P(failure1-p+1 - dbinom(6, n, p
 +sum(dbinom(0:5, n, p)) 
 +</code>  
 +<code> 
 +> p <1/4 
 +> q <- 1-p 
 +> n <6 
 +> pbinom(5, n, p) 
 +[1] 0.9997559 
 +> 1 - dbinom(6, n, p) 
 +[1] 0.9997559 
 +> sum(dbinom(0:5, n, p)) 
 +[1] 0.9997559 
 +>  
 +</code>
  
-X = 0, 1 (failure and success) +중요 . . . .  
-$P(X=x) = p^{x}(1-p)^{1-x}$ or  +<code> 
-$P(x) = p^{x}(1-p)^{1-x}$+# http://commres.net/wiki/mean_and_variance_of_binomial_distribution 
 +# ################################################################## 
 +# 
 +<- 1/4 
 +q <- 1 - p 
 +n <- 5 
 +r <- 0 
 +all.dens <- dbinom(0:n, n, p
 +all.dens 
 +sum(all.dens)
  
-참고. +choose(5,0)*p^0*(q^(5-0)) 
-| x  |   | +choose(5,1)*p^1*(q^(5-1)) 
-p(x (1-p)   +choose(5,2)*p^2*(q^(5-2)
 +choose(5,3)*p^3*(q^(5-3)) 
 +choose(5,4)*p^4*(q^(5-4)
 +choose(5,5)*p^5*(q^(5-5)) 
 +all.dens
  
-When x = 0 (failure)$P(X = 0) p^{0}(1-p)^{1-0} = (1-p)$ = Probability of failure +choose(5,0)*p^0*(q^(5-0)) +  
-When x = 1 (success), $P(X = 1p^{1}(1-p)^{0} = p Probability of success+  choose(5,1)*p^1*(q^(5-1)) +  
 +  choose(5,2)*p^2*(q^(5-2)) +  
 +  choose(5,3)*p^3*(q^(5-3)) +  
 +  choose(5,4)*p^4*(q^(5-4)) +  
 +  choose(5,5)*p^5*(q^(5-5)) 
 +sum(all.dens) 
 +#  
 +(p+q)^
 +# note that n whatever, (p+q)^n 1
  
-<WRAP box> +</code>
-Bernoulli distribution expands to binomial distribution, geometric distribution, etc. +
-Binomial distribution = The distribution of number of success in n independent Bernoulli trials. +
-Geometric distribution = The distribution of number of trials to get the first success in independent Bernoulli trials. +
-</WRAP>+
  
-$P(X=x) = p^{x}(1-p)^{1-x}$ or  +<code> 
-$P(x) = p^{x}(1-p)^{1-x}$ +> # http://commres.net/wiki/mean_and_variance_of_binomial_distribution 
-X takes, x = 0, 1 +> # ################################################################## 
- +> # 
-==== Expectation and Variance value ==== +<- 1/4 
-\begin{eqnarray*} +> q <- 1 - p 
-E(X& = & \sum_{x}xP(x) \\ +> n <5 
-& = & 0*p^{0}(1-p)^{1-0} + 1*p^{1}(1-p)^{1-1}  \\ +> r <- 0 
-& = & p \\ +> all.dens <- dbinom(0:nn, p) 
-\\ +> all.dens 
-Var(X& = & E((X-\mu)^{2}\\ +[1] 0.2373046875 0.3955078125 0.2636718750 0.0878906250 
-& = & \sum_{x}(x-\mu)^2P(x\\ +[5] 0.0146484375 0.0009765625 
-\end{eqnarray*} +> sum(all.dens
-그런데  +[1] 1 
-\begin{eqnarray*+>  
-E((X-\mu)^{2}& = & E(X^2(E(X))^2 \\ +> choose(5,0)*p^0*(q^(5-0)
-\end{eqnarray*} +[10.2373047 
- +> choose(5,1)*p^1*(q^(5-1)) 
-위에서  +[1] 0.3955078 
-\begin{eqnarray*} +> choose(5,2)*p^2*(q^(5-2)) 
-E(X^{2}& = & \sum x^2 p(x) \\ +[1] 0.2636719 
-& = & 0^2*p^0(1-p)^{1-0+ 1^2*p^1(1-p)^{1-1} \\ +> choose(5,3)*p^3*(q^(5-3)
-& = & p +[1] 0.08789062 
-\end{eqnarray*} +> choose(5,4)*p^4*(q^(5-4)) 
- +[1] 0.01464844 
-zero squared probability of zero occurring +> choose(5,5)*p^5*(q^(5-5)) 
-one squared prob of one occurring  +[1] 0.0009765625 
- +> all.dens 
-또한 $E(X$ 임을 알고 있음 +[1] 0.2373046875 0.3955078125 0.2636718750 0.0878906250 
-\begin{eqnarray*+[5] 0.0146484375 0.0009765625 
-Var(X) & = & E((X-\mu)^{2}\\ +>  
-& = & E(X^2- (E(X))^2 \\ +> choose(5,0)*p^0*(q^(5-0))  
-& = & p - p^2 \\ ++   choose(5,1)*p^1*(q^(5-1)) +  
-& = & p(1-p++   choose(5,2)*p^2*(q^(5-2)) +  
-\end{eqnarray*} ++   choose(5,3)*p^3*(q^(5-3)) +  
- ++   choose(5,4)*p^4*(q^(5-4)) +  
-위는 First Head Statistics 에서 $X \sim (10.25)$ 에서 E(X)와 Var(X)를 구한 후 (각각, p와 pq), X가 n가지가 있다고 확장하여 np와 npq를 구한 것과 같다. 즉, 교재는 Bernoulli distribution을 이야기(설명)하지 않고활용하여 binomial distribution의 기대값과 분산값을 구해낸 것이다.  ++   choose(5,5)*p^5*(q^(5-5)) 
- +[1] 
-==== Proof of E and Var from Bernoulli Distribution ==== +> sum(all.dens
- +[1] 1 
-$E(U_{i}p$  and $Var(U_{i}) = p(1-p)$ or $Var(U_{i}= p \cdot q$ +> #  
- +(p+q)^
-$$X = U_{1} + . . . . + U_{n}$$ +[1] 1 
-\begin{eqnarray*} +> # note that n = whatever, (p+q)^n = 1 
-E(X) & = & E(U_{1} + . . + U_{n}\\ + 
-& = & E(U_{1}) + . . . + E(U_{n}) \\ +</code> 
-& = & p + . . . + p \\ +====Proof of Binomial Expected Value and Variance ===== 
-& = & np +[[:Mean and Variance of Binomial Distribution|이항분포에서의 기댓값과 분산에 대한 수학적 증명]], Mathematical proof of Binomial Distribution Expected value and Variance
-\end{eqnarray*} +
- +
-\begin{eqnarray*} +
-Var(X& = & Var(U_{1} + . . . + U_{n}) \\ +
-& = & Var(U_{1}) + . . . + Var(U_{n}) \\ +
-& p(1-p. . . + p(1-p\\ +
-& np(1-p) \\ +
-& = & npq  +
-\end{eqnarray*} +
- +
- +
-==== From a scratch (Proof of Binomial Expected Value==== +
-[[:Mean and Variance of Binomial Distribution|Mathematical proof of Binomial Distribution Expected value and Variance]]+
 ====== Poisson Distribution ====== ====== Poisson Distribution ======
 $$X \sim Po(\lambda)$$ $$X \sim Po(\lambda)$$
Line 956: Line 1193:
 \end{eqnarray*} \end{eqnarray*}
  
-왜 $e^{\lambda} = \left(1 + \lambda + \dfrac{\lambda^{2}}{2!} + \dfrac{\lambda^{3}}{3!} + . . . \right)$ 인지는 [[:Taylor series]] 문서를 참조.+왜 $e^{\lambda} = \left(1 + \lambda + \dfrac{\lambda^{2}}{2!} + \dfrac{\lambda^{3}}{3!} + . . . \right)$ 인지는 [[:Taylor series]] 문서를 참조.  
 +이것이 의미하는 것은 r이 0에서 무한대로 갈 때의 확률값의 분포를 말하므로 전체 분포가 1이 됨을 의미한다. 아래 "What does the Poisson distribution look like?" 참조
  
 <code> <code>
Line 967: Line 1205:
 위의 그림은 lambda는 2, 즉 한달에 아주대학교 앞의 건널목 주변 찻길에서 교통사고가 날 횟수가 2회라고 할 때, X=3 이므로 3번 교통사고가 일어날 확률을 (P(X=3)) 묻는 문제이다. 위의 그림은 lambda는 2, 즉 한달에 아주대학교 앞의 건널목 주변 찻길에서 교통사고가 날 횟수가 2회라고 할 때, X=3 이므로 3번 교통사고가 일어날 확률을 (P(X=3)) 묻는 문제이다.
 \begin{eqnarray*} \begin{eqnarray*}
-P(X = 3) & = & \frac {e^{-2} * 2^{3}}{3!} \\+P(X = 3) & = & e^{-2} * \frac {2^{3}}{3!} \\
 & = & 0.180 & = & 0.180
 \end{eqnarray*} \end{eqnarray*}
Line 1011: Line 1249:
 [{{:b:head_first_statistics:pasted:20191107-095627.png|Figure 1. lambda=30}}] [{{:b:head_first_statistics:pasted:20191107-095627.png|Figure 1. lambda=30}}]
  
-lambda가 클 수록 좌우대칭의 종형분포를 이루고 ((Figure 1)), 작을 수로 오른 쪽으로 편향된 (skewed to the right) 혹은 양의방향으로 편향된(positively skewed) 분포를 ((Figure 2)) 이룬다.+lambda가 클 수록 좌우대칭의 종형분포를 이루고 ((Figure 1)), 작을 수록 오른 쪽으로 편향된 (skewed to the right) 혹은 양의방향으로 편향된(positively skewed) 분포를 ((Figure 2)) 이룬다.
  
 <code> <code>
Line 1049: Line 1287:
  
 \begin{eqnarray*} \begin{eqnarray*}
-P(X=0) & = & \frac{e^{-3.4}*3.4^{0}} {0!}  \\+P(X=0) & = & e^{-3.4} * \frac{3.4^{0}} {0!}  \\
 & = & e^{-3.4} \\ & = & e^{-3.4} \\
 & = & 0.03337327  & = & 0.03337327 
Line 1055: Line 1293:
  
 <code> <code>
 +# R 에서 계산
 > e^(-3.4) > e^(-3.4)
 +[1] 0.03337327
 +
 +# 혹은 
 +> dpois(0, 3.4)
 [1] 0.03337327 [1] 0.03337327
  
 </code> </code>
 +
 +포아송 분포를 따르는 확률에서 아무것도 일어나지 않을 때의 확률은 e<sup>-lambda </sup>가 된다. 예를 들면 119 전화가 한시간에 걸려오는 확률이 5번이라고 할 때,  지난 한 시간동안 한 건의 전화도 없을 확률은? 
 +\begin{eqnarray*}
 +P(X=0) & = & e^{-5} * \frac{5^{0}} {0!}  \\
 +& = & e^{-5} \\
 +& = & 0.006737947
 +\end{eqnarray*}
 +<code>
 +> lamba <- 5
 +> e <- exp(1)
 +> px.0 <- e^(-lamba)
 +
 +> px.0
 +[1] 0.006737947
 +
 +# or 
 +> dpois(0,5)
 +[1] 0.006737947
 +</code>
 +
 +
  
 __2. What’s the probability of the machine malfunctioning three times next week?__ __2. What’s the probability of the machine malfunctioning three times next week?__
Line 1143: Line 1407:
 **How did Kate find the probability so quickly, and avoid the error on her calculator?** **How did Kate find the probability so quickly, and avoid the error on her calculator?**
 </WRAP> </WRAP>
 +우선 위의 문제를 binomial distribution 문제로 생각하면 답은 
 +\begin{eqnarray*}
 +P(r=15) & = & _{100}C_{15} * 0.1^{15} * 0.99^{85}\\
 +\end{eqnarray*}
 +라고 볼 수 있다. 
  
 \begin{eqnarray} \begin{eqnarray}
Line 1180: Line 1449:
 b(100, 0.1)이므로  b(100, 0.1)이므로 
 n*p = 10 = lambda  n*p = 10 = lambda 
-따라서+따라서 Pois 분포로 보는 답은  
 +lambda = 10 일때 P(r=15)값을 구하는 문제로  
 + 
 +\begin{eqnarray*} 
 +P(r = 15) & = & e^{-10} * \frac {10^{15}}{15!} \\ 
 +& = & 0.0347180 
 +\end{eqnarray*}
 <code> <code>
 > dpois(x=15, lambda=10) > dpois(x=15, lambda=10)
Line 1300: Line 1575:
  
 <WRAP box> <WRAP box>
-2. On average, 1 bus stops at a certain point every 15 minutes. What’s the probability that no buses will turn up in a single 15 minute interval?+2. On average, 1 bus stops at a certain point every 15 minutes. What’s the probability that __<fc #ff0000>no buses</fc>__ will turn up in a single 15 minute interval?
  
 위는 Poisson distribution 문제이므로 기대값과 분산값은 각각 lambda 값인 1 (15분마다 1대씩 버스가 온다고 한다) 위는 Poisson distribution 문제이므로 기대값과 분산값은 각각 lambda 값인 1 (15분마다 1대씩 버스가 온다고 한다)
b/head_first_statistics/geometric_binomial_and_poisson_distributions.1697607465.txt.gz · Last modified: by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki