====== Proof of Binomial Expected Value, from a scratch ====== see [[:The Binomial Theorem]] \begin{eqnarray*} \text{The binomial theorem} & & \\ (a + b)^{m} & = & \sum^{m}_{y=0}{{m}\choose{y}} a^{y} b^{m-y} \\ \end{eqnarray*} 위의 식이 복잡해 보이지만 m = 3 일때의 이항정리식을 말한다 \begin{align*} \sum^{m}_{y=0}{{m}\choose{y}} a^{y} b^{m-y} \text{, m = 3} \\ \end{align*} \begin{align*} \sum^{3}_{y=0}{{3}\choose{y}} a^{y} b^{3-y} & = {{3}\choose{0}} a^{0} b^{3-0} + {{3}\choose{1}} a^{1} b^{3-1} + {{3}\choose{2}} a^{2} b^{3-2} + {{3}\choose{3}} a^{y} b^{3-3} \\ & = 1*a^0*b^3 + 3*a^1*b^2 + 3*a^2*b^1 + 1*a^3*b^0 \\ & = a^3 + 3 a^2 b^1 + 3 a^1 b^2 + b^3 \\ \end{align*} ====== For Mean ====== \begin{eqnarray*} E(X) & = & \sum_{x}x p(x) \;\;\; \because \; p(x) = {{n}\choose{x}} p^x (1-p)^{n-x} \\ & = & \sum_{x=0}^{n} x {{n} \choose {x}} p^x(1-p)^{n-x} \\ & = & \sum_{x=0}^{n} x \frac{n!}{x!(n-x)!} p^x(1-p)^{n-x} \\ \text{note that } x! = x(x-1)! \\ & = & \sum_{x=1}^{n} \frac{n!}{(x-1)!(n-x)!} p^x(1-p)^{n-x} \\ \text{cause we know that E(x) = np,} \\ \text{we extract np outside from summation} \\ \text{note that } p^x = p * p^{x-1} \\ \text{and } n! = n * (n-1)! \\ & = & \sum_{x=1}^{n} \frac{\underline{n}*(n-1)!}{(x-1)!(n-x)!} (\underline{p}*p^{x-1})(1-p)^{n-x} \\ \text{we take out the underlined part} \\ \text{(that is, np) out of the sigma part } \\ & = & np \sum_{x=1}^{n} \frac{(n-1)!}{(x-1)!(n-x)!} p^{x-1}(1-p)^{n-x} \\ & = & np \underline{ \sum_{x=1}^{n} {\frac{(n-1)!}{(x-1)!(n-x)!} p^{x-1}(1-p)^{n-x}}} \\ \text{we want to check the underlined} \\ \text{part is equal to one so that np is left out} \\ n-x = (n-1)-(x-1) \\ & = & np \sum_{x=1}^{n} \frac{(n-1)!}{(x-1)!((n-1)-(x-1))!} p^{x-1}(1-p)^{(n-1)-(x-1)} \\ m = n - 1 \\ y = x - 1 \\ & = & np \sum_{y=0}^{m} \frac{(m)!}{(y)!(m-y))!} p^{y}(1-p)^{(m-y)} \\ & = & np \sum_{y=0}^{m} \frac{(m)!}{(y)!(m-y))!} p^{y}(1-p)^{(m-y)} \\ & = & np \sum_{y=0}^{m} {{m}\choose {y}} p^{y}(1-p)^{(m-y)} \\ \text{Recall that} \\ \sum^{m}_{y=0}{{m}\choose{y}} a^{y} b^{m-y} = (a + b)^{m} \\ & = & np\;(p + (1-p))^m \\ & = & np\;(1)^m \\ & = & np \\ \end{eqnarray*} ====== For variance ====== \begin{align*} Var(X) & = E[(X-\mu)^2] \\ & = \sum_{x}(x-\mu)^2p(x) \\ \text{We also know that: } \\ E[(X-\mu)^2] & = E(X^2) - [E(X)]^2 \\ \end{align*} \begin{align*} E(X^2) & = \sum_{x=0}^{n} x^2 p(x) \\ & = \sum_{x=0}^{n} x^2 {{n}\choose{x}} p^x (1-p)^{n-x} \;\;\; \because \; p(x) = {{n}\choose{x}} p^x (1-p)^{n-x} \\ & = \sum_{x=0}^{n} x^2 \frac{n!}{x!(n-x)!} p^x (1-p)^{n-x} \\ \end{align*} 그런데 $E(X^2)$ 대신 $E[X(X-1)]$을 생각해보면 \begin{align*} E[X(X-1)] & = \sum_{x=0}^{n} x(x-1) \frac{n!}{x!(n-x)!} p^x (1-p)^{n-x} \\ & = \sum_{x=2}^{n} \frac{n!}{(x-2)!(n-x)!} p^x (1-p)^{n-x} \;\; \because \; x! = x (x-1) (x-2)! \\ & = n(n-1)p^2 \sum_{x=2}^{n} \frac{(n-2)!}{(x-2)!(n-x)!} p^{x-2} (1-p)^{n-x} \\ \text{cause} \\ n - x = (n - 2)-(x - 2) \\ & = n(n-1)p^2 \sum_{x=2}^{n} \frac{(n-2)!}{(x-2)!((n-2)-(x-2))!} p^{x-2} (1-p)^{(n-2)-(x-2)} \\ m = n - 2 \\ y = x - 2 \\ & = n(n-1)p^2 \sum_{y=0}^{m} \frac{m!}{y!((m-y))!} p^{y} (1-p)^{(m-y)} \\ & = n(n-1)p^2 \underline {\sum_{y=0}^{m} \frac{m!}{y!((m-y))!} p^{y} (1-p)^{m-y} } \\ & = n(n-1)p^2 \underline {\sum_{y=0}^{m} {{m}\choose{y}} p^{y} (1-p)^{m-y} } \\ \text {we know that the underline part is} \\ (p+(1-p))^m \\ \text {and, we also know that it is 1} \\ (p+(1-p))^m = 1^m \\ & = n(n-1)p^2 (p + (1-p))^m \\ & = n(n-1)p^2 \\ \end{align*} . . . . \begin{align*} E[X(X - 1)] & = n(n-1)p^2 \\ E[X^2 - X] & = n(n-1)p^2 \\ E[X^2]- E[X] & = n(n-1)p^2 \;\;\; \because E[X] = np \\ E[X^2]- np & = n(n-1)p^2 \\ E[X^2]& = n(n-1)p^2 + np \\ \\ \end{align*} \begin{align*} Var(X) & = E[X^2] - [E(X)]^2 \\ & = \left[n(n-1)p^2 + np \right] - \left[np \right]^2 \\ & = np[(n-1)p + 1 - np] \\ & = np[np - p + 1 - np] \\ & = np(1 - p) \\ & = npq \\ \\ \end{align*}