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 [2025/10/06 20:53] – [Expectation and Variance of] hkimscilb:head_first_statistics:geometric_binomial_and_poisson_distributions [2025/10/06 23:43] (current) – [e.g.,] hkimscil
Line 797: Line 797:
  
 ===== 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. This is called Bernoulli distribution.
Line 862: Line 877:
 c <- choose(n,r)  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) 
 </code> </code>
 +
 <code> <code>
 > p <- .25 > p <- .25
Line 873: 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
  
  
 </code> </code>
 +
 +
 +
 +
 +
  
 Ans 2.  Ans 2. 
Line 888: 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)
 +
 </code> </code>
 <code> <code>
Line 899: Line 936:
 > 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 964: Line 1022:
 > </code> > </code>
  
-===== Another way to see E(X) and Var(X) ===== +Q. 한 문제를 맞힐 확률은 1/4 이다총 여섯 문제가 있다고 할 때, 0에서 5 문제를 맞힐 확률은dbinom을 이용해서 구하시오. 
-==== Bernoulli Distribution ==== +<code> 
-Toss a fair coin onceWhat 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) = p +pbinom(5, n, p)
-  * P(failure= 1-p+
  
-X = 0, 1 (failure and success+- dbinom(6, n, p
-$P(X=x) = p^{x}(1-p)^{1-x}$ or  +</code>  
-$P(x) = p^{x}(1-p)^{1-x}$+<code> 
 +<- 1/4 
 +> q <- 1-p 
 +> n <- 6 
 +> pbinom(5, n, p
 +[1] 0.9997559 
 +1 - dbinom(6, n, p) 
 +[1] 0.9997559
  
-참고. +</code>
-| 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+<code> 
 +# http://commres.net/wiki/mean_and_variance_of_binomial_distribution 
 +# ################################################################## 
 +
 +<- 1/4 
 +q <- 1 - p 
 +n <- 5 
 +r <- 0 
 +all.dens <- dbinom(0:nn, p) 
 +all.dens 
 +sum(all.dens)
  
-<WRAP box> +choose(5,0)*p^0*(q^(5-0)) 
-Bernoulli distribution expands to binomial distributiongeometric distributionetc. +choose(5,1)*p^1*(q^(5-1)) 
-Binomial distribution = The distribution of number of success in n independent Bernoulli trials. +choose(5,2)*p^2*(q^(5-2)) 
-Geometric distribution = The distribution of number of trials to get the first success in independent Bernoulli trials. +choose(5,3)*p^3*(q^(5-3)) 
-</WRAP>+choose(5,4)*p^4*(q^(5-4)) 
 +choose(5,5)*p^5*(q^(5-5)) 
 +all.dens
  
-$P(X=xp^{x}(1-p)^{1-x}$ or  +choose(5,0)*p^0*(q^(5-0)) +  
-$P(xp^{x}(1-p)^{1-x}$ +  choose(5,1)*p^1*(q^(5-1)) +  
-X takes0, 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)^n 
 +# note that n whatever(p+q)^n = 1
  
-==== Expectation and Variance value ==== +</code>
-\begin{eqnarray*} +
-E(X) & = & \sum_{x}xP(x) \\ +
-& = & 0*p^{0}(1-p)^{1-0} + 1*p^{1}(1-p)^{1-1}  \\ +
-& = & p \\ +
-\\ +
-Var(X) & = & E((X-\mu)^{2}) \\ +
-& = & \sum_{x}(x-\mu)^2P(x) \\ +
-\end{eqnarray*} +
-그런데  +
-\begin{eqnarray*} +
-E((X-\mu)^{2}) & = & E(X^2) - (E(X))^2 \\ +
-\end{eqnarray*}+
  
-위에서  +<code> 
-\begin{eqnarray*} +> # http://commres.net/wiki/mean_and_variance_of_binomial_distribution 
-E(X^{2}& = & \sum x^2 p(x\\ +> # ################################################################## 
-& = & 0^2*p^0(1-p)^{1-0} + 1^2*p^1(1-p)^{1-1} \\ +> # 
-& = & p +> p <- 1/4 
-\end{eqnarray*} +> q <- 1 - p 
- +> n <- 5 
-zero squared probability of zero occurring +> r <- 0 
-one squared prob of one occurring  +> all.dens <- dbinom(0:n, n, p) 
- +> 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}\\ +sum(all.dens
-& = & E(X^2- (E(X))^2 \\ +[1] 1 
-& = & p - p^2 \\ +>  
-& = & p(1-p+> choose(5,0)*p^0*(q^(5-0)
-\end{eqnarray*} +[10.2373047 
- +> choose(5,1)*p^1*(q^(5-1)) 
-위는 First Head Statistics 에서 $X \sim (10.25)$ 에서 E(X)와 Var(X)를 구한 후 (각각, p와 pq), X가 n가지가 있다고 확장하여 np와 npq를 구한 것과 같다. 즉, 교재는 Bernoulli distribution을 이야기(설명)하지 않고, 활용하여 binomial distribution의 기대값과 분산값을 구해낸 것이다.  +[1] 0.3955078 
- +> choose(5,2)*p^2*(q^(5-2)) 
-==== extension of Bernoulli Distribution ==== +[1] 0.2636719 
- +> choose(5,3)*p^3*(q^(5-3)
-$E(U_{i}p$  and $Var(U_{i}) = p(1-p)$ or $Var(U_{i}= p \cdot q$ +[10.08789062 
- +> choose(5,4)*p^4*(q^(5-4)) 
-$$X = U_{1} + . . . . + U_{n}$$ +[1] 0.01464844 
-\begin{eqnarray*} +> choose(5,5)*p^5*(q^(5-5)) 
-E(X& = & E(U_{1} . . . U_{n}\\ +[1] 0.0009765625 
-& = & E(U_{1}) + . . . E(U_{n}\\ +> all.dens 
-& = & + . . . + p \\ +[1] 0.2373046875 0.3955078125 0.2636718750 0.0878906250 
-& = & np +[5] 0.0146484375 0.0009765625 
-\end{eqnarray*+>  
- +> choose(5,0)*p^0*(q^(5-0))  
-\begin{eqnarray*} +  choose(5,1)*p^1*(q^(5-1)) +  
-Var(X) & = & Var(U_{1} . . . U_{n}\\ +  choose(5,2)*p^2*(q^(5-2))  
-& = & Var(U_{1}) + . . . Var(U_{n}\\ +  choose(5,3)*p^3*(q^(5-3)) +  
-& = & p(1-p) + . . . + p(1-p\\ +  choose(5,4)*p^4*(q^(5-4)) +  
-& = & np(1-p) \\ +  choose(5,5)*p^5*(q^(5-5)
-& npq  +[1] 1 
-\end{eqnarray*} +> sum(all.dens) 
- +[1] 1 
- +> #  
-===== From a scratch (Proof of Binomial Expected Value=====+> (p+q)^n 
 +[1] 1 
 +> # note that n whatever, (p+q)^n = 1 
 + 
 +</code> 
 +===== 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.1759751599.txt.gz · Last modified: by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki