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/06 23:43] (current) – [e.g.,] hkimscil | ||
---|---|---|---|
Line 877: | Line 877: | ||
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 894: | ||
> 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 920: | ||
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 936: | ||
> 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 1022: | ||
> </ | > </ | ||
- | ===== 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