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 [2025/10/06 20:57] – [extension of Bernoulli Distribution] hkimscil | b:head_first_statistics:geometric_binomial_and_poisson_distributions [2025/10/13 08:59] (current) – [Binomial Distributions] hkimscil | ||
---|---|---|---|
Line 73: | 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: | ||
</ | </ | ||
Line 87: | 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: | ||
</ | </ | ||
- | {{: | + | < |
+ | {{: | ||
r번 시도한 이후, 그 이후 어디서든지 간에 성공을 얻을 확률 | r번 시도한 이후, 그 이후 어디서든지 간에 성공을 얻을 확률 | ||
$$ P(X > r) = q^{r} $$ | $$ P(X > r) = q^{r} $$ | ||
Line 737: | Line 739: | ||
$Var(X) = \displaystyle \frac{q}{p^{2}}$ | $Var(X) = \displaystyle \frac{q}{p^{2}}$ | ||
+ | < | ||
+ | > 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: | ||
+ | [1] 0.8704 | ||
+ | > pgeom(3, p) | ||
+ | [1] 0.8704 | ||
+ | > | ||
+ | > q^4 | ||
+ | [1] 0.1296 | ||
+ | > 1-sum(dgeom(0: | ||
+ | [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 | ||
+ | > | ||
+ | </ | ||
Line 787: | 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 |
+ | \text{c.f., | ||
+ | \displaystyle _{n} P_{r} & = & \displaystyle \dfrac {n!} {(n-r)!} \\ | ||
\end{eqnarray*} | \end{eqnarray*} | ||
+ | |||
+ | see [[: | ||
+ | |||
p = 각 시행에서 성공할 확률 | p = 각 시행에서 성공할 확률 | ||
Line 877: | Line 917: | ||
c <- choose(n, | c <- choose(n, | ||
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) | ||
</ | </ | ||
+ | |||
< | < | ||
> p <- .25 | > p <- .25 | ||
Line 888: | Line 934: | ||
> 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 | ||
> | > | ||
> | > | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
Ans 2. | Ans 2. | ||
Line 903: | Line 960: | ||
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) | ||
+ | |||
</ | </ | ||
< | < | ||
Line 914: | Line 976: | ||
> ans2 | > ans2 | ||
[1] 0.08789062 | [1] 0.08789062 | ||
+ | > | ||
+ | > choose(n, | ||
+ | [1] 0.08789062 | ||
+ | > | ||
+ | > dbinom(r, n, p) | ||
+ | [1] 0.08789063 | ||
+ | > | ||
> | > | ||
</ | </ | ||
- | Ans 3. | + | Ans 3. 중요 |
< | < | ||
- | ans1 + ans2 | + | ans1 + ans2 |
+ | dbinom(2, 5, .25) + dbinom(3, 5, .25) | ||
+ | dbinom(2:3, 5, .25) | ||
+ | sum(dbinom(2: | ||
+ | pbinom(3, 5, .25) - pbinom(1, 5, .25) | ||
</ | </ | ||
- | < | + | < |
+ | > 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: | ||
+ | [1] 0.3515625 | ||
+ | > pbinom(3, 5, .25) - pbinom(1, 5, .25) | ||
+ | [1] 0.3515625 | ||
+ | > | ||
</ | </ | ||
Line 979: | Line 1062: | ||
> </ | > </ | ||
- | ===== Another way to see E(X) and Var(X) ===== | + | Q. 한 문제를 맞힐 확률은 1/4 이다. 총 여섯 문제가 있다고 할 때, 0에서 5 문제를 맞힐 확률은? dbinom을 이용해서 구하시오. |
+ | < | ||
+ | p <- 1/4 | ||
+ | q <- 1-p | ||
+ | n <- 6 | ||
+ | pbinom(5, n, p) | ||
+ | 1 - dbinom(6, n, p) | ||
+ | </ | ||
+ | < | ||
+ | > p <- 1/4 | ||
+ | > q <- 1-p | ||
+ | > n <- 6 | ||
+ | > pbinom(5, n, p) | ||
+ | [1] 0.9997559 | ||
+ | > 1 - dbinom(6, n, p) | ||
+ | [1] 0.9997559 | ||
+ | </ | ||
- | ===== From a scratch (Proof of Binomial Expected Value) ===== | + | 중요 . . . . |
+ | < | ||
+ | # http:// | ||
+ | # ################################################################## | ||
+ | # | ||
+ | p <- 1/4 | ||
+ | q <- 1 - p | ||
+ | n <- 5 | ||
+ | r <- 0 | ||
+ | all.dens <- dbinom(0:n, n, p) | ||
+ | all.dens | ||
+ | sum(all.dens) | ||
+ | |||
+ | choose(5, | ||
+ | choose(5, | ||
+ | choose(5, | ||
+ | choose(5, | ||
+ | choose(5, | ||
+ | choose(5, | ||
+ | all.dens | ||
+ | |||
+ | choose(5, | ||
+ | choose(5, | ||
+ | choose(5, | ||
+ | choose(5, | ||
+ | choose(5, | ||
+ | choose(5, | ||
+ | sum(all.dens) | ||
+ | # | ||
+ | (p+q)^n | ||
+ | # note that n = whatever, (p+q)^n = 1 | ||
+ | |||
+ | </ | ||
+ | |||
+ | < | ||
+ | > # http:// | ||
+ | > # ################################################################## | ||
+ | > # | ||
+ | > p <- 1/4 | ||
+ | > q <- 1 - p | ||
+ | > n <- 5 | ||
+ | > r <- 0 | ||
+ | > all.dens <- dbinom(0:n, n, p) | ||
+ | > all.dens | ||
+ | [1] 0.2373046875 0.3955078125 0.2636718750 0.0878906250 | ||
+ | [5] 0.0146484375 0.0009765625 | ||
+ | > sum(all.dens) | ||
+ | [1] 1 | ||
+ | > | ||
+ | > choose(5, | ||
+ | [1] 0.2373047 | ||
+ | > choose(5, | ||
+ | [1] 0.3955078 | ||
+ | > choose(5, | ||
+ | [1] 0.2636719 | ||
+ | > choose(5, | ||
+ | [1] 0.08789062 | ||
+ | > choose(5, | ||
+ | [1] 0.01464844 | ||
+ | > choose(5, | ||
+ | [1] 0.0009765625 | ||
+ | > all.dens | ||
+ | [1] 0.2373046875 0.3955078125 0.2636718750 0.0878906250 | ||
+ | [5] 0.0146484375 0.0009765625 | ||
+ | > | ||
+ | > choose(5, | ||
+ | + | ||
+ | + | ||
+ | + | ||
+ | + | ||
+ | + | ||
+ | [1] 1 | ||
+ | > sum(all.dens) | ||
+ | [1] 1 | ||
+ | > # | ||
+ | > (p+q)^n | ||
+ | [1] 1 | ||
+ | > # note that n = whatever, (p+q)^n = 1 | ||
+ | > | ||
+ | </ | ||
+ | ===== Proof of Binomial Expected Value and Variance | ||
[[:Mean and Variance of Binomial Distribution|이항분포에서의 기댓값과 분산에 대한 수학적 증명]], Mathematical proof of Binomial Distribution Expected value and Variance | [[:Mean and Variance of Binomial Distribution|이항분포에서의 기댓값과 분산에 대한 수학적 증명]], Mathematical proof of Binomial Distribution Expected value and Variance | ||
====== Poisson Distribution ====== | ====== Poisson Distribution ====== |
b/head_first_statistics/geometric_binomial_and_poisson_distributions.1759751877.txt.gz · Last modified: by hkimscil