PDF version
PDF & CDF
The probability density function is $$f(x; \mu, \sigma) = {1\over\sqrt{2\pi}\sigma}e^{-{1\over2}{(x-\mu)^2\over\sigma^2}}$$ The cumulative distribution function is defined by $$F(x; \mu, \sigma) = \Phi\left({x-\mu\over\sigma}\right)$$ where $$\Phi(z) = {1\over\sqrt{2\pi}} \int_{-\infty}^{z}e^{-{1\over2}x^2}\ dx$$
Proof:
$$
\begin{align*}
\int_{-\infty}^{\infty}f(x; \mu, \sigma) &= \int_{-\infty}^{\infty}{1\over\sqrt{2\pi}\sigma}e^{-{1\over2}{(x-\mu)^2\over\sigma^2}}\ dx\\
&= {1\over\sqrt{2\pi}\sigma}\int_{-\infty}^{\infty}e^{-{1\over2}{(x-\mu)^2\over\sigma^2}}\ dx\\
&= {1\over\sqrt{2\pi}}\int_{-\infty}^{\infty}e^{-{1\over2}y^2}\ dy\quad\quad\quad\quad\quad(\mbox{setting}\ y={x-\mu\over\sigma} \Rightarrow dx = \sigma dy)\\
\end{align*}
$$
Let $I = \int_{-\infty}^{\infty}e^{-{1\over2}y^2}\ dy$, then
$$
\begin{eqnarray*}
I^2 &=& \int_{-\infty}^{\infty}e^{-{1\over2}y^2}\ dy\int_{-\infty}^{\infty}e^{-{1\over2}x^2}\ dx\\
&=& \int_{-\infty}^{\infty}\int_{-\infty}^{\infty}e^{-{1\over2}(y^2+x^2)}\ dydx\quad\quad\quad\quad(\mbox{setting}\ x=r\cos\theta, y=r\sin\theta)\\
&=& \int_{0}^{\infty}\int_{0}^{2\pi}e^{-{1\over2}r^2}\ rd\theta dr \\
& & (\mbox{double integral}\ \iint\limits_{D}f(x, y)\ dxdy = \iint\limits_{D^*}f(r\cos\theta, r\sin\theta)r\ drd\theta) \\
&=& 2\pi\int_{0}^{\infty}re^{-{1\over2}r^2}\ dr\\
&=& -2\pi e^{-{1\over2}r^2}\Big|_{0}^{\infty}\\
&=& 2\pi
\end{eqnarray*}
$$
Hence $$\int_{-\infty}^{\infty}f(x; \mu, \sigma) = {1\over\sqrt{2\pi}} \cdot\sqrt{2\pi} = 1$$
Standard Normal Distribution
If $X$ is normally distributed with parameters $\mu$ and $\sigma^2$, then $$Z = {X-\mu\over\sigma}$$ is normally distributed with parameters 0 and 1.
Proof:
An important conclusion is that if $X$ is normally distributed with parameters $\mu$ and $\sigma^2$, then $Y = aX + b$ is normally distributed with parameters $a\mu + b$ and $a^2\sigma^2$. Denote $F_{Y}$ as the cumulative distribution function of $Y$:
$$
\begin{align*}
F_{Y}(x) &= P(Y \leq x)\\
&= P(aX + b \leq x)\\
&= P(X \leq {x-b\over a})\\
&= F_{X}\left({x-b\over a}\right)
\end{align*}
$$
where $F_{X}(x)$ is the cumulative distribution function of $X$. By differentiation, the probability density function of $Y$ is
$$
\begin{align*}
f_{Y}(x) &= {1\over a}f_{X}\left({x-b\over a}\right)\\
&= {1\over\sqrt{2\pi}a\sigma}e^{-{1\over2}{({x-b\over a} - \mu)^2\over \sigma^2}}\\
&= {1\over\sqrt{2\pi}(a\sigma)}e^{-{1\over2}{(x-b - a\mu)^2\over a^2\sigma^2}}\\
&= {1\over\sqrt{2\pi}(a\sigma)}e^{-{1\over2}{(x-(b + a\mu))^2\over (a\sigma)^2}}
\end{align*}
$$
which shows that $Y$ is normally distributed with parameters $a\mu + b$ and $a^2\sigma^2$.
According to the above result, we can easily deduce that $Z = {X-\mu\over\sigma}$ follows the normally distributed with parameters 0 and 1.
Mean
The expected value is $$E[X] = \mu$$
Proof:
$$
\begin{align*}
E[Z] &= \int_{-\infty}^{\infty}xf_{Z}(x)\ dx\quad\quad\quad \quad\quad \quad\quad (\mbox{setting}\ Z={X-\mu\over\sigma})\\
&= {1\over\sqrt{2\pi}}\int_{-\infty}^{\infty}xe^{-{1\over2}x^2}\ dx\\
&= -{1\over\sqrt{2\pi}}\int_{-\infty}^{\infty}e^{-{1\over2}x^2}\ d\left(-{1\over2}x^2\right)\\
&= -{1\over\sqrt{2\pi}}e^{-{1\over2}x^2}\Big|_{-\infty}^{\infty}\\
&= 0
\end{align*}
$$
Hence
$$
\begin{align*}
E[X] &= E\left[\sigma Z+\mu\right]\\
&= \sigma E[Z] + \mu\\
&= \mu
\end{align*}
$$
Variance
The variance is $$\mbox{Var}(X) = \sigma^2$$
Proof:
$$
\begin{align*}
E\left[Z^2\right] &= {1\over\sqrt{2\pi}}\int_{-\infty}^{\infty}x^2e^{-{1\over2}x^2}\ dx\quad\quad\quad \quad\quad \quad\quad\quad\quad\quad (\mbox{setting}\ Z={X-\mu\over\sigma})\\
&= {1\over\sqrt{2\pi}}\left(-xe^{-{1\over2}x^2}\Big|_{-\infty}^{\infty} +\int_{-\infty}^{\infty}e^{-{1\over2}x^2}\ dx\right)\quad\quad\quad(\mbox{integrating by parts})\\
&= {1\over\sqrt{2\pi}}\int_{-\infty}^{\infty}e^{-{1\over2}x^2}\ dx \quad\quad\quad\quad\quad\quad\quad(\mbox{standard normal distribution})\\
&= 1
\end{align*}
$$
the integral by parts: $$u= x,\ dv = xe^{-{1\over2}x^2}\ dx$$ $$\implies du = dx,\ v = \int xe^{-{1\over2}x^2}\ dx = -e^{-{1\over2}x^2}$$ $$\implies \int x^2e^{-{1\over2}x^2}\ dx =-xe^{-{1\over2}x^2} +\int e^{-{1\over2}x^2}\ dx$$ Hence $$\mbox{Var}(X) = \mbox{Var}(\sigma Z + \mu)= \sigma^2\mbox{Var}(Z) = \sigma^2$$
Basic Concept of Probability Distributions 5: Hypergemometric Distribution
PDF version
PMF
Suppose that a sample of size $n$ is to be chosen randomly (without replacement) from an urn containing $N$ balls, of which $m$ are white and $N-m$ are black. If we let $X$ denote the number of white balls selected, then $$f(x; N, m, n) = \Pr(X = x) = {{m\choose x}{N-m\choose n-x}\over {N\choose n}}$$ for $x= 0, 1, 2, \cdots, n$.
Proof:
This is essentially the Vandermonde's identity:
$${m+n\choose r} = \sum_{k=0}^{r}{m\choose k}{n\choose r-k}$$ where $m$, $n$, $k$, $r\in \mathbb{N}_0$.
Because
$$
\begin{align*}
\sum_{r=0}^{m+n}{m+n\choose r}x^r &= (1+x)^{m+n} \quad\quad\quad\quad\quad\quad\quad\quad \mbox{(binomial theorem)}\\
&= (1+x)^m(1+x)^n\\
&= \left(\sum_{i=0}^{m}{m\choose i}x^{i}\right)\left(\sum_{j=0}^{n}{n\choose j}x^{j}\right)\\
&= \sum_{r=0}^{m+n}\left(\sum_{k=0}^{r}{m\choose k}{n\choose r-k}\right)x^r \quad\quad\mbox{(product of two binomials)}
\end{align*}
$$
Using the product of two binomials:
$$
\begin{eqnarray*}
\left(\sum_{i=0}^{m}a_i x^i\right)\left(\sum_{j=0}^{n}b_j x^j\right) &=& \left(a_0+a_1x+\cdots + a_mx^m\right)\left(b_0+b_1x+\cdots + b_nx^n\right)\\
&=& a_0b_0 + a_0b_1x +a_1b_0x +\cdots +a_0b_2x^2 + a_1b_1x^2 + a_2b_0x^2 +\\
& &\cdots + a_mb_nx^{m+n}\\
&=& \sum_{r=0}^{m+n}\left(\sum_{k=0}^{r}a_{k}b_{r-k}\right)x^{r}
\end{eqnarray*}
$$
Hence
$$
\begin{eqnarray*}
& &\sum_{r=0}^{m+n}{m+n\choose r}x^r = \sum_{r=0}^{m+n}\left(\sum_{k=0}^{r}{m\choose k}{n\choose r-k}\right)x^r\\
&\implies& {m+n\choose r} = \sum_{k=0}^{r}{m\choose k}{n\choose r-k}\\
& \implies& \sum_{k=0}^{r}{{m\choose k}{n\choose r-k}\over {m+n\choose r}} = 1
\end{eqnarray*}
$$
Mean
The expected value is $$\mu = E[X] = {nm\over N}$$
Proof:
$$
\begin{eqnarray*}
E[X^k] &=& \sum_{x=0}^{n}x^kf(x; N, m, n)\\
&=& \sum_{x=0}^{n}x^k{{m\choose x}{N-m\choose n-x}\over {N\choose n}}\\
&=& {nm\over N}\sum_{x=0}^{n} x^{k-1} {{m-1 \choose x-1}{N-m\choose n-x}\over {N-1 \choose n-1}}\\
& & (\mbox{identities:}\ x{m\choose x} = m{m-1\choose x-1},\ n{N\choose n} = N{N-1\choose n-1})\\
&=& {nm\over N}\sum_{x=0}^{n} (y+1)^{k-1} {{m-1 \choose y}{(N-1) - (m - 1)\choose (n-1)-y}\over {N-1 \choose n-1}}\quad\quad(\mbox{setting}\ y=x-1)\\
&=& {nm\over N}E\left[(Y+1)^{k-1}\right] \quad\quad\quad \quad\quad \quad\quad\quad\quad (\mbox{since}\ Y\sim g(y; m-1, n-1, N-1))
\end{eqnarray*}
$$
Hence, setting $k=1$ we have $$E[X] = {nm\over N}$$ Note that this follows the mean of the binomial distribution $\mu = np$, where $p = {m\over N}$.
Variance
The variance is $$\sigma^2 = \mbox{Var}(X) = np(1-p)\left(1 - {n-1 \over N-1}\right)$$ where $p = {m\over N}$.
Proof:
$$
\begin{align*}
E[X^2] &= {nm\over N}E[Y+1] \quad\quad\quad \quad\quad\quad \quad (\mbox{setting}\ k=2)\\
&= {nm\over N}\left(E[Y] + 1\right)\\
& = {nm\over N}\left[{(n-1) (m-1) \over N-1}+1\right]
\end{align*}
$$
Hence the variance is
$$
\begin{align*}
\mbox{Var}(X) &= E\left[X^2\right] - E[X]^2\\
&= {mn\over N}\left[{(n-1) (m-1) \over N-1}+1 - {nm\over N}\right]\\
&= np \left[ (n-1) \cdot {pN-1\over N-1}+1-np\right] \quad\quad \quad \quad \quad\quad(\mbox{setting}\ p={m\over N})\\
&= np\left[(n-1)\cdot {p(N-1) + p -1 \over N-1} + 1 -np\right]\\
&= np\left[(n-1)p + (n-1)\cdot{p-1 \over N-1} + 1-np\right]\\
&= np\left[1-p - (1-p)\cdot {n-1\over N-1}\right] \\
&= np(1-p)\left(1 - {n-1 \over N-1}\right)
\end{align*}
$$
Note that it is approximately equal to 1 when $N$ is sufficient large (i.e. ${n-1\over N-1}\rightarrow 0$ when $N\rightarrow +\infty$). And then it is the same as the variance of the binomial distribution $\sigma^2 = np(1-p)$, where $p = {m\over N}$.
PMF
Suppose that a sample of size $n$ is to be chosen randomly (without replacement) from an urn containing $N$ balls, of which $m$ are white and $N-m$ are black. If we let $X$ denote the number of white balls selected, then $$f(x; N, m, n) = \Pr(X = x) = {{m\choose x}{N-m\choose n-x}\over {N\choose n}}$$ for $x= 0, 1, 2, \cdots, n$.
Proof:
This is essentially the Vandermonde's identity:
$${m+n\choose r} = \sum_{k=0}^{r}{m\choose k}{n\choose r-k}$$ where $m$, $n$, $k$, $r\in \mathbb{N}_0$.
Because
$$
\begin{align*}
\sum_{r=0}^{m+n}{m+n\choose r}x^r &= (1+x)^{m+n} \quad\quad\quad\quad\quad\quad\quad\quad \mbox{(binomial theorem)}\\
&= (1+x)^m(1+x)^n\\
&= \left(\sum_{i=0}^{m}{m\choose i}x^{i}\right)\left(\sum_{j=0}^{n}{n\choose j}x^{j}\right)\\
&= \sum_{r=0}^{m+n}\left(\sum_{k=0}^{r}{m\choose k}{n\choose r-k}\right)x^r \quad\quad\mbox{(product of two binomials)}
\end{align*}
$$
Using the product of two binomials:
$$
\begin{eqnarray*}
\left(\sum_{i=0}^{m}a_i x^i\right)\left(\sum_{j=0}^{n}b_j x^j\right) &=& \left(a_0+a_1x+\cdots + a_mx^m\right)\left(b_0+b_1x+\cdots + b_nx^n\right)\\
&=& a_0b_0 + a_0b_1x +a_1b_0x +\cdots +a_0b_2x^2 + a_1b_1x^2 + a_2b_0x^2 +\\
& &\cdots + a_mb_nx^{m+n}\\
&=& \sum_{r=0}^{m+n}\left(\sum_{k=0}^{r}a_{k}b_{r-k}\right)x^{r}
\end{eqnarray*}
$$
Hence
$$
\begin{eqnarray*}
& &\sum_{r=0}^{m+n}{m+n\choose r}x^r = \sum_{r=0}^{m+n}\left(\sum_{k=0}^{r}{m\choose k}{n\choose r-k}\right)x^r\\
&\implies& {m+n\choose r} = \sum_{k=0}^{r}{m\choose k}{n\choose r-k}\\
& \implies& \sum_{k=0}^{r}{{m\choose k}{n\choose r-k}\over {m+n\choose r}} = 1
\end{eqnarray*}
$$
Mean
The expected value is $$\mu = E[X] = {nm\over N}$$
Proof:
$$
\begin{eqnarray*}
E[X^k] &=& \sum_{x=0}^{n}x^kf(x; N, m, n)\\
&=& \sum_{x=0}^{n}x^k{{m\choose x}{N-m\choose n-x}\over {N\choose n}}\\
&=& {nm\over N}\sum_{x=0}^{n} x^{k-1} {{m-1 \choose x-1}{N-m\choose n-x}\over {N-1 \choose n-1}}\\
& & (\mbox{identities:}\ x{m\choose x} = m{m-1\choose x-1},\ n{N\choose n} = N{N-1\choose n-1})\\
&=& {nm\over N}\sum_{x=0}^{n} (y+1)^{k-1} {{m-1 \choose y}{(N-1) - (m - 1)\choose (n-1)-y}\over {N-1 \choose n-1}}\quad\quad(\mbox{setting}\ y=x-1)\\
&=& {nm\over N}E\left[(Y+1)^{k-1}\right] \quad\quad\quad \quad\quad \quad\quad\quad\quad (\mbox{since}\ Y\sim g(y; m-1, n-1, N-1))
\end{eqnarray*}
$$
Hence, setting $k=1$ we have $$E[X] = {nm\over N}$$ Note that this follows the mean of the binomial distribution $\mu = np$, where $p = {m\over N}$.
Variance
The variance is $$\sigma^2 = \mbox{Var}(X) = np(1-p)\left(1 - {n-1 \over N-1}\right)$$ where $p = {m\over N}$.
Proof:
$$
\begin{align*}
E[X^2] &= {nm\over N}E[Y+1] \quad\quad\quad \quad\quad\quad \quad (\mbox{setting}\ k=2)\\
&= {nm\over N}\left(E[Y] + 1\right)\\
& = {nm\over N}\left[{(n-1) (m-1) \over N-1}+1\right]
\end{align*}
$$
Hence the variance is
$$
\begin{align*}
\mbox{Var}(X) &= E\left[X^2\right] - E[X]^2\\
&= {mn\over N}\left[{(n-1) (m-1) \over N-1}+1 - {nm\over N}\right]\\
&= np \left[ (n-1) \cdot {pN-1\over N-1}+1-np\right] \quad\quad \quad \quad \quad\quad(\mbox{setting}\ p={m\over N})\\
&= np\left[(n-1)\cdot {p(N-1) + p -1 \over N-1} + 1 -np\right]\\
&= np\left[(n-1)p + (n-1)\cdot{p-1 \over N-1} + 1-np\right]\\
&= np\left[1-p - (1-p)\cdot {n-1\over N-1}\right] \\
&= np(1-p)\left(1 - {n-1 \over N-1}\right)
\end{align*}
$$
Note that it is approximately equal to 1 when $N$ is sufficient large (i.e. ${n-1\over N-1}\rightarrow 0$ when $N\rightarrow +\infty$). And then it is the same as the variance of the binomial distribution $\sigma^2 = np(1-p)$, where $p = {m\over N}$.
Basic Concept of Probability Distributions 3: Geometric Distribution
PDF version
PMF
Suppose that independent trials, each having a probability $p$, $0 < p < 1$, of being a success, are performed until a success occurs. If we let $X$ equal the number of failures required, then the geometric distribution mass function is $$f(x; p) =\Pr(X=x) = (1-p)^{x}p$$ for $x=0, 1, 2, \cdots$.
Proof:
$$
\begin{align*}
\sum_{x=0}^{\infty}f(x; p) &= \sum_{x=0}^{\infty}(1-p)^{x}p\\
&= p\sum_{x=0}^{\infty}(1-p)^{x}\\
& = p\cdot {1\over 1-(1-p)}\\
& = 1
\end{align*}
$$
Mean
The expected value is $$\mu = E[X] = {1-p\over p}$$
Proof:
Firstly, we know that $$\sum_{x=0}^{\infty}p^x = {1\over 1-p}$$ where $0 < p < 1$. Thus $$ \begin{align*} {d\over dp}\sum_{x=0}^{\infty}p^x &= \sum_{x=1}^{\infty}xp^{x-1}\\ &= {1\over(1-p)^2} \end{align*} $$ The expected value is $$ \begin{align*} E[X] &= \sum_{x=0}^{\infty}x(1-p)^{x}p\\ &=p(1-p)\sum_{x=1}^{\infty}x(1-p)^{x-1}\\ &= p(1-p){1\over(1-(1-p))^2}\\ &= {1-p\over p} \end{align*} $$ Variance
The variance is $$\sigma^2 = \mbox{Var}(X) = {1-p\over p^2}$$
Proof:
$$
\begin{align*}
E\left[X^2\right] &=\sum_{x=0}^{\infty}x^2(1-p)^{x}p\\
&= (1-p)\sum_{x=1}^{\infty}x^2(1-p)^{x-1}p
\end{align*}
$$
Rewrite the right hand summation as
$$
\begin{align*}
\sum_{x=1}^{\infty} x^2(1-p)^{x-1}p&= \sum_{x=1}^{\infty} (x-1+1)^2(1-p)^{x-1}p\\
&= \sum_{x=1}^{\infty} (x-1)^2(1-p)^{x-1}p + \sum_{x=1}^{\infty} 2(x-1)(1-p)^{x-1}p + \sum_{x=1}^{\infty} (1-p)^{x-1}p\\
&= E\left[X^2\right] + 2E[X] + 1\\
&= E\left[X^2\right] + {2-p\over p}
\end{align*}
$$
Thus $$E\left[X^2\right] = (1-p)E\left[X^2\right] + {(1-p)(2-p) \over p}$$ That is $$E\left[X^2\right]= {(1-p)(2-p)\over p^2}$$
So the variance is
$$
\begin{align*}
\mbox{Var}(X) &= E\left[X^2\right] - E[X]^2\\
&= {(1-p)(2-p)\over p^2} - {(1-p)^2\over p^2}\\
&= {1-p\over p^2}
\end{align*}
$$
PMF
Suppose that independent trials, each having a probability $p$, $0 < p < 1$, of being a success, are performed until a success occurs. If we let $X$ equal the number of failures required, then the geometric distribution mass function is $$f(x; p) =\Pr(X=x) = (1-p)^{x}p$$ for $x=0, 1, 2, \cdots$.
Proof:
$$
\begin{align*}
\sum_{x=0}^{\infty}f(x; p) &= \sum_{x=0}^{\infty}(1-p)^{x}p\\
&= p\sum_{x=0}^{\infty}(1-p)^{x}\\
& = p\cdot {1\over 1-(1-p)}\\
& = 1
\end{align*}
$$
Mean
The expected value is $$\mu = E[X] = {1-p\over p}$$
Proof:
Firstly, we know that $$\sum_{x=0}^{\infty}p^x = {1\over 1-p}$$ where $0 < p < 1$. Thus $$ \begin{align*} {d\over dp}\sum_{x=0}^{\infty}p^x &= \sum_{x=1}^{\infty}xp^{x-1}\\ &= {1\over(1-p)^2} \end{align*} $$ The expected value is $$ \begin{align*} E[X] &= \sum_{x=0}^{\infty}x(1-p)^{x}p\\ &=p(1-p)\sum_{x=1}^{\infty}x(1-p)^{x-1}\\ &= p(1-p){1\over(1-(1-p))^2}\\ &= {1-p\over p} \end{align*} $$ Variance
The variance is $$\sigma^2 = \mbox{Var}(X) = {1-p\over p^2}$$
Proof:
$$
\begin{align*}
E\left[X^2\right] &=\sum_{x=0}^{\infty}x^2(1-p)^{x}p\\
&= (1-p)\sum_{x=1}^{\infty}x^2(1-p)^{x-1}p
\end{align*}
$$
Rewrite the right hand summation as
$$
\begin{align*}
\sum_{x=1}^{\infty} x^2(1-p)^{x-1}p&= \sum_{x=1}^{\infty} (x-1+1)^2(1-p)^{x-1}p\\
&= \sum_{x=1}^{\infty} (x-1)^2(1-p)^{x-1}p + \sum_{x=1}^{\infty} 2(x-1)(1-p)^{x-1}p + \sum_{x=1}^{\infty} (1-p)^{x-1}p\\
&= E\left[X^2\right] + 2E[X] + 1\\
&= E\left[X^2\right] + {2-p\over p}
\end{align*}
$$
Thus $$E\left[X^2\right] = (1-p)E\left[X^2\right] + {(1-p)(2-p) \over p}$$ That is $$E\left[X^2\right]= {(1-p)(2-p)\over p^2}$$
So the variance is
$$
\begin{align*}
\mbox{Var}(X) &= E\left[X^2\right] - E[X]^2\\
&= {(1-p)(2-p)\over p^2} - {(1-p)^2\over p^2}\\
&= {1-p\over p^2}
\end{align*}
$$
Basic Concept of Probability Distributions 2: Poisson Distribution
PDF version
PMF
A discrete random variable $X$ is said to have a Poisson distribution with parameter $\lambda > 0$, if the probability mass function of $X$ is given by $$f(x; \lambda) = \Pr(X=x) = e^{-\lambda}{\lambda^x\over x!}$$ for $x=0, 1, 2, \cdots$.
Proof:
$$
\begin{align*}
\sum_{x=0}^{\infty}f(x; \lambda) &= \sum_{x=0}^{\infty} e^{-\lambda}{\lambda^x\over x!}\\
& = e^{-\lambda}\sum_{x=0}^{\infty}{\lambda^x\over x!}\\
&= e^{-\lambda}\left(1 + \lambda + {\lambda^2 \over 2!}+ {\lambda^3\over 3!}+ \cdots\right)\\
& = e^{-\lambda} \cdot e^{\lambda}\\
& = 1
\end{align*}
$$
Mean
The expected value is $$\mu = E[X] = \lambda$$
Proof:
$$
\begin{align*}
E[X] &= \sum_{x=0}^{\infty}xe^{-\lambda}{\lambda^x\over x!}\\
& = \sum_{x=1}^{\infty}e^{-\lambda}{\lambda^x\over (x-1)!}\\
& =\lambda e^{-\lambda}\sum_{x=1}^{\infty}{\lambda^{x-1}\over (x-1)!}\\
& = \lambda e^{-\lambda}\left(1+\lambda + {\lambda^2\over 2!} + {\lambda^3\over 3!}+\cdots\right)\\
& = \lambda e^{-\lambda} e^{\lambda}\\
& = \lambda
\end{align*}
$$
Variance
The variance is $$\sigma^2 = \mbox{Var}(X) = \lambda$$
Proof:
$$
\begin{align*}
E\left[X^2\right] &= \sum_{x=0}^{\infty}x^2e^{-\lambda}{\lambda^x\over x!}\\
&= \sum_{x=1}^{\infty}xe^{-\lambda}{\lambda^x\over (x-1)!}\\
&= \lambda\sum_{x=1}^{\infty}xe^{-\lambda}{\lambda^{x-1}\over (x-1)!}\\
& = \lambda\sum_{x=1}^{\infty}(x-1+1)e^{-\lambda}{\lambda^{x-1}\over (x-1)!}\\
&= \lambda\left(\sum_{x=1}^{\infty}(x-1)e^{-\lambda}{\lambda^{x-1}\over (x-1)!} + \sum_{x=1}^{\infty} e^{-\lambda}{\lambda^{x-1}\over (x-1)!}\right)\\
&= \lambda\left(\lambda\sum_{x=2}^{\infty}e^{-\lambda}{\lambda^{x-2}\over (x-2)!} + \sum_{x=1}^{\infty} e^{-\lambda}{\lambda^{x-1}\over (x-1)!}\right)\\
& = \lambda(\lambda+1)
\end{align*}
$$
Hence the variance is
$$
\begin{align*}
\mbox{Var}(X)& = E\left[X^2\right] - E[X]^2\\
& = \lambda(\lambda + 1) - \lambda^2\\
& = \lambda
\end{align*}
$$
PMF
A discrete random variable $X$ is said to have a Poisson distribution with parameter $\lambda > 0$, if the probability mass function of $X$ is given by $$f(x; \lambda) = \Pr(X=x) = e^{-\lambda}{\lambda^x\over x!}$$ for $x=0, 1, 2, \cdots$.
Proof:
$$
\begin{align*}
\sum_{x=0}^{\infty}f(x; \lambda) &= \sum_{x=0}^{\infty} e^{-\lambda}{\lambda^x\over x!}\\
& = e^{-\lambda}\sum_{x=0}^{\infty}{\lambda^x\over x!}\\
&= e^{-\lambda}\left(1 + \lambda + {\lambda^2 \over 2!}+ {\lambda^3\over 3!}+ \cdots\right)\\
& = e^{-\lambda} \cdot e^{\lambda}\\
& = 1
\end{align*}
$$
Mean
The expected value is $$\mu = E[X] = \lambda$$
Proof:
$$
\begin{align*}
E[X] &= \sum_{x=0}^{\infty}xe^{-\lambda}{\lambda^x\over x!}\\
& = \sum_{x=1}^{\infty}e^{-\lambda}{\lambda^x\over (x-1)!}\\
& =\lambda e^{-\lambda}\sum_{x=1}^{\infty}{\lambda^{x-1}\over (x-1)!}\\
& = \lambda e^{-\lambda}\left(1+\lambda + {\lambda^2\over 2!} + {\lambda^3\over 3!}+\cdots\right)\\
& = \lambda e^{-\lambda} e^{\lambda}\\
& = \lambda
\end{align*}
$$
Variance
The variance is $$\sigma^2 = \mbox{Var}(X) = \lambda$$
Proof:
$$
\begin{align*}
E\left[X^2\right] &= \sum_{x=0}^{\infty}x^2e^{-\lambda}{\lambda^x\over x!}\\
&= \sum_{x=1}^{\infty}xe^{-\lambda}{\lambda^x\over (x-1)!}\\
&= \lambda\sum_{x=1}^{\infty}xe^{-\lambda}{\lambda^{x-1}\over (x-1)!}\\
& = \lambda\sum_{x=1}^{\infty}(x-1+1)e^{-\lambda}{\lambda^{x-1}\over (x-1)!}\\
&= \lambda\left(\sum_{x=1}^{\infty}(x-1)e^{-\lambda}{\lambda^{x-1}\over (x-1)!} + \sum_{x=1}^{\infty} e^{-\lambda}{\lambda^{x-1}\over (x-1)!}\right)\\
&= \lambda\left(\lambda\sum_{x=2}^{\infty}e^{-\lambda}{\lambda^{x-2}\over (x-2)!} + \sum_{x=1}^{\infty} e^{-\lambda}{\lambda^{x-1}\over (x-1)!}\right)\\
& = \lambda(\lambda+1)
\end{align*}
$$
Hence the variance is
$$
\begin{align*}
\mbox{Var}(X)& = E\left[X^2\right] - E[X]^2\\
& = \lambda(\lambda + 1) - \lambda^2\\
& = \lambda
\end{align*}
$$
Basic Concept of Probability Distributions 1: Binomial Distribution
PDF version
PMF
If the random variable $X$ follows the binomial distribution with parameters $n$ and $p$, we write $X \sim B(n, p)$.
The probability of getting exactly $x$ successes in $n$ trials is given by the probability mass function: $$f(x; n, p) = \Pr(X=x) = {n\choose x}p^{x}(1-p)^{n-x}$$ for $x=0, 1, 2, \cdots$ and ${n\choose x} = {n!\over(n-x)!x!}$.
Proof:
$$
\begin{align*}
\sum_{x=0}^{\infty}f(x; n, p) &= \sum_{x=0}^{\infty}{n\choose x}p^{x}(1-p)^{n-x}\\
&= [p + (1-p)]^{n}\;\;\quad\quad \mbox{(binomial theorem)}\\
&= 1
\end{align*}
$$
Mean
The expected value is $$\mu = E[X] = np$$
Proof:
$$
\begin{align*}
E\left[X^k\right] &= \sum_{x=0}^{\infty}x^{k}{n\choose x}p^{x}(1-p)^{n-x}\\
&= \sum_{x=1}^{\infty}x^{k}{n\choose x}p^{x}(1-p)^{n-x}\\
&= np\sum_{x=1}^{\infty}x^{k-1}{n-1\choose x-1}p^{x-1}(1-p)^{n-x}\quad\quad\quad (\mbox{identity}\ x{n\choose x} = n{n-1\choose x-1})\\
&= np\sum_{y=0}^{\infty}(y+1)^{k-1}{n-1\choose y}p^{y}(1-p)^{n-1-y}\quad(\mbox{substituting}\ y=x-1)\\
&= npE\left[(Y + 1)^{k-1}\right] \quad\quad\quad \quad\quad\quad \quad\quad\quad\quad\quad (Y\sim B(n-1, p)) \\
\end{align*}
$$
Using the identity
$$
\begin{align*}
x{n\choose x} &= {x\cdot n!\over(n-x)!x!}\\
& = {n!\over(n-x)!(x-1)!}\\
&= n{(n-1)!\over[(n-1)-(x-1)]!(x-1)!}\\
&= n{n-1\choose x-1}
\end{align*}
$$
Hence setting $k=1$ we have $$E[X] = np$$
Variance
The variance is $$\sigma^2 = \mbox{Var}(X) = np(1-p)$$
Proof:
$$
\begin{align*}
\mbox{Var}(X) &= E\left[X^2\right] - E[X]^2\\
&= npE[Y+1] - n^2p^2\\
& = np\left(E[Y] + 1\right) - n^2p^2\\
& = np[(n-1)p + 1] - n^2p^2\quad\quad (Y\sim B(n-1, p))\\
&= np(1-p)
\end{align*}
$$
PMF
If the random variable $X$ follows the binomial distribution with parameters $n$ and $p$, we write $X \sim B(n, p)$.
The probability of getting exactly $x$ successes in $n$ trials is given by the probability mass function: $$f(x; n, p) = \Pr(X=x) = {n\choose x}p^{x}(1-p)^{n-x}$$ for $x=0, 1, 2, \cdots$ and ${n\choose x} = {n!\over(n-x)!x!}$.
Proof:
$$
\begin{align*}
\sum_{x=0}^{\infty}f(x; n, p) &= \sum_{x=0}^{\infty}{n\choose x}p^{x}(1-p)^{n-x}\\
&= [p + (1-p)]^{n}\;\;\quad\quad \mbox{(binomial theorem)}\\
&= 1
\end{align*}
$$
Mean
The expected value is $$\mu = E[X] = np$$
Proof:
$$
\begin{align*}
E\left[X^k\right] &= \sum_{x=0}^{\infty}x^{k}{n\choose x}p^{x}(1-p)^{n-x}\\
&= \sum_{x=1}^{\infty}x^{k}{n\choose x}p^{x}(1-p)^{n-x}\\
&= np\sum_{x=1}^{\infty}x^{k-1}{n-1\choose x-1}p^{x-1}(1-p)^{n-x}\quad\quad\quad (\mbox{identity}\ x{n\choose x} = n{n-1\choose x-1})\\
&= np\sum_{y=0}^{\infty}(y+1)^{k-1}{n-1\choose y}p^{y}(1-p)^{n-1-y}\quad(\mbox{substituting}\ y=x-1)\\
&= npE\left[(Y + 1)^{k-1}\right] \quad\quad\quad \quad\quad\quad \quad\quad\quad\quad\quad (Y\sim B(n-1, p)) \\
\end{align*}
$$
Using the identity
$$
\begin{align*}
x{n\choose x} &= {x\cdot n!\over(n-x)!x!}\\
& = {n!\over(n-x)!(x-1)!}\\
&= n{(n-1)!\over[(n-1)-(x-1)]!(x-1)!}\\
&= n{n-1\choose x-1}
\end{align*}
$$
Hence setting $k=1$ we have $$E[X] = np$$
Variance
The variance is $$\sigma^2 = \mbox{Var}(X) = np(1-p)$$
Proof:
$$
\begin{align*}
\mbox{Var}(X) &= E\left[X^2\right] - E[X]^2\\
&= npE[Y+1] - n^2p^2\\
& = np\left(E[Y] + 1\right) - n^2p^2\\
& = np[(n-1)p + 1] - n^2p^2\quad\quad (Y\sim B(n-1, p))\\
&= np(1-p)
\end{align*}
$$
Study Notes of "Introduction to MATRIX ALGEBRA": 8. Gauss-Seidel Method
PDF format lecture Chapter 8 Gauss-Seidel Method
Printable version Study Notes of “Introduction to MATRIX ALGEBRA”
Summary
Printable version Study Notes of “Introduction to MATRIX ALGEBRA”
Summary
- Algorithm
Given a general set of $n$ equations and $n$ unknowns $$\begin{cases}a_{11}x_1 + a_{12}x_2 +\cdots + a_{1n}x_n = c_1 \\ a_{21}x_1 + a_{22}x_2 +\cdots + a_{2n}x_n = c_2 \\ \vdots\\ a_{n1}x_1 + a_{n2}x_2 +\cdots + a_{nn}x_n = c_n \\\end{cases}$$ If the diagonal elements are non-zero, each equation is rewritten for the corresponding unknown, that is, $$\begin{cases}x_1 = \displaystyle{c_1-a_{12}x_2 - a_{13}x_3-\cdots -a_{1n}x_n\over a_{11}}\\ x_2 = \displaystyle{c_2-a_{21}x_1 - a_{23}x_3-\cdots -a_{2n}x_n\over a_{22}}\\ \vdots\\ x_n = \displaystyle{c_n-a_{n1}x_1 - a_{n2}x_2-\cdots -a_{n,n-1}x_{n-1}\over a_{11}}\\ \end{cases}$$ $$\Rightarrow \begin{cases}x_1 = \displaystyle{c_1-\displaystyle\sum_{j=1,j\neq1}^{n}a_{1j}x_j\over a_{11}}\\ x_2 = \displaystyle{c_1-\displaystyle\sum_{j=1,j\neq2}^{n}a_{2j}x_j\over a_{22}}\\ \vdots\\ x_n = \displaystyle{c_n-\displaystyle\sum_{j=1,j\neq n}^{n}a_{nj}x_j\over a_{nn}}\\ \end{cases}$$ Hence for any row $i$, $$x_i = {c_i-\displaystyle\sum_{j=1,j\neq i}^{n}a_{ij}x_j\over a_{ii}}$$ where $i=1$, $2$, $\cdots$, $n$. - Iteration
To find $x_i$, we assume an initial guess for the $x_i$ and then use the rewritten equations to calculate the new estimates. We always use the most recent estimates to calculate the next estimates, $x_i$. At the end of each iteration, we calculate the absolute relative approximate error for each $x_i$ as $$\varepsilon_i = \left|{x_i^{\text{new}} - x_i^{\text{old}}\over x_i^{\text{new}}}\right|$$ where $x_i^{\text{new}}$ is the recently obtained value of $x_i$, and $x_i^{\text{old}}$ is the previous value of $x_i$. When the absolute relative approximate error for each $x_i$ is less than the pre-specified tolerance, the iterations are stopped. - Convergent
The coefficient matrix $[A]$ in $[A][X]=[B]$ must be diagonally dominant, that is, $$\begin{cases}|a_{ii}| \geq \displaystyle\sum_{j=1, j\neq i}^{n}a_{ij}&\text{for all}\ i\\ |a_{ii}| > \displaystyle\sum_{j=1, j\neq i}^{n}a_{ij} & \text{for at least one}\ i\end{cases}$$ - An example
Suppose the following system of equations $$\begin{cases}12x_1 + 3x_2 -5x_3 =1\\ x_1 + 5x_2 +3x_3 =28\\ 3x_1 + 7x_2 +13x_3 =76\end{cases}$$ Use $$\begin{bmatrix}x_1\\ x_2\\ x_3 \end{bmatrix} = \begin{bmatrix}1\\ 0\\ 1\end{bmatrix}$$ as the initial guess and conduct two iterations.
- Diagonally dominant test: $$\begin{cases}|a_{11}|=12 > |a_{12}| + |a_{13}| = 3+5=8\\ |a_{22}|=5 > |a_{21}| + |a_{23}|=1+3=4\\ |a_{33}|=13 > |a_{31}|+|a_{32}| = 3+7=10 \end{cases}$$ Hence the solution should converge using Gauss Seidel method.
- Rewriting the equations: $$\begin{cases}x_1 = \displaystyle{1-3x_2 +5x_3 \over 12}\\ x_2 = \displaystyle{28-x_1-3x_3\over 5}\\ x_3= \displaystyle{76-3x_1-7x_2\over 13}\end{cases}$$ And the initial value is $$\begin{bmatrix}x_1\\ x_2\\ x_3 \end{bmatrix} = \begin{bmatrix}1\\ 0\\ 1\end{bmatrix}$$
- Iteration 1: $$\begin{cases}x_1 = \displaystyle{1 - 3\times0 + 5\times1 \over 12} = 0.5\\ x_2 = \displaystyle{28 - 0.5 - 3\times1 \over 5} = 4.9\\ x_3= \displaystyle{76-3\times 0.5-7\times 4.9\over 13}=3.0923\end{cases}$$ Notice that the second and the third equations above, $x_1$ and $x_2$ are updated immediately.
And the absolute relative approximate error is $$\begin{cases}\varepsilon_1 = \displaystyle{|0.5-1|\over0.5} = 1\\ \varepsilon_2 = \displaystyle{|4.9 - 0|\over 4.9} = 1\\ \varepsilon_3 = \displaystyle{|3.0923 - 1|\over3.0923}=0.67662 \end{cases}$$ - Iteration 2: $$\begin{cases}x_1 = \displaystyle{1 - 3\times4.9 + 5\times3.0923 \over 12} = 0.14679\\ x_2 = \displaystyle{28 - 0.14679 - 3\times3.0923 \over 5} = 3.7153\\ x_3= \displaystyle{76-3\times 0.14679-7\times 3.7153\over 13} = 3.8118 \end{cases}$$ And the absolute relative approximate error is $$\begin{cases}\varepsilon_1 = \displaystyle{|0.14679-0.5|\over0.14679} = 2.4\\ \varepsilon_2 = \displaystyle{|3.7153 - 4.9|\over 3.7153} = 0.31889\\ \varepsilon_3 = \displaystyle{|3.8118 - 3.0923|\over3.8118}=0.18874 \end{cases}$$
- Final result:
After 6 iterations, we have the solution $$\begin{bmatrix}x_1\\ x_2\\ x_3 \end{bmatrix} = \begin{bmatrix}0.99919\\ 3.0001\\ 4.0001 \end{bmatrix}$$ which is very close to the exact solution $$\begin{bmatrix}x_1\\ x_2\\ x_3 \end{bmatrix} = \begin{bmatrix}1\\ 3\\ 4 \end{bmatrix}$$
Solution Manual of MOOCULUS-2 "Sequences and Series": 3. Convergence tests
The printable textbook of PDF format can be downloaded via MOOCULUS-2 Textbook
The printable solution manual of PDF format can be downloaded via MOOCULUS-2 Solution
Summary
The printable solution manual of PDF format can be downloaded via MOOCULUS-2 Solution
Summary
- Ratio Test
Consider the series $\sum_{n=0}^\infty a_n$ where each term $a_n$ is positive.
Suppose that $$\lim_{n\to \infty} \frac{a_{n+1}}{a_n}=L$$ Then,
- if $L < 1$ the series $\sum_{n=0}^\infty a_n$ converges.
- if $L > 1$ the series diverges.
- if $L=1$ this test is inconclusive.
- Integral Test
Suppose that $f(x)>0$ and is decreasing on the infinite interval $[k,\infty)$ (for some $k\ge1$) and that $a_n=f(n)$. Then the series $$\sum_{n=k}^\infty a_n$$ converges if and only if the improper integral $$\int_{k}^\infty f(x)\,dx$$ converges. - $p$-series
Recall that a $p$-series is any series of the form $$\sum_{n=1}^\infty 1/n^p$$ A $p$-series converges if and only if $p>1$. - Root Test
Consider the series $\sum_{n=0}^\infty a_n$ where each term $a_n$ is positive. Suppose that $$\lim_{n\to \infty} \left(a_n\right)^{1/n}=L$$ Then,
- if $L < 1$ the series $\sum a_n$ converges,
- if $L > 1$ the series diverges, and
- if $L=1$, then the root test is inconclusive.
- Determine a series convergent or divergent:
- $n^{\text{th}}$ test, if $$\lim_{n\to\infty}a_n\neq0$$ then it diverges; otherwise, using other tests;
- Comparison test, $p$-series test, ratio test, integral test, root test, and Cauchy test.
BerkeleyX Stat2.3x Inference Notes: FINAL
Full Solution Manual of PDF Format
ADDITIONAL PRACTICE FOR THE FINAL
In the following problems you will be asked to choose one of the four options (A)-(D). The options are stated here once and for all. If you pick any option other than (A), you must fill in all blanks correctly for credit. Use the 5% cutoff for P.
(A) The question cannot be answered based on the information given.
(B) one-sample $z$ = ( ); P approx ( ); Conclusion: ( ).
(C) two-sample $z$ = ( ); P approx ( ); Conclusion: ( ).
(D) one-sample $t$ = ( ); d.f. = ( ); P approx ( ); Conclusion: ( ).
PROBLEM 1
A die is rolled 600 times. The face with six spots comes up 126 times. Does the die land "six" with chance 1/6? Or are there too many sixes? Answer the question in the following steps:
a) State the null hypothesis.
b) State the alternative hypothesis.
c) Under the null hypothesis, the number of sixes in the 600 rolls is expected to be ( ), give or take ( ).
d) In this context, pick one of the options (A)-(D).
Solution
a) Null $H_0: p = \frac{1}{6}$
b) Alternative $H_A: p >\frac{1}{6}$
c) $$E=n\cdot p=600\times\frac{1}{6}=100$$ $$\sigma=\sqrt{p\cdot(1-p)\cdot n}=\sqrt{\frac{1}{6}\times\frac{5}{6}\times600}=9.128709$$
d) This is one-sample $z$ test, (B) is correct. $$z=\frac{126-100}{\sigma}$$ and P-value is 0.002198659 which is smaller than 0.05, so we reject $H_0$. Thus the conclusion is $p > \frac{1}{6}$. R code:
A simple random sample of 6 students is taken from among all students in a university. The average age of the sampled students is 20 years with an SD of 3 years. Someone wants to test the hypothesis that the average age of students in the university is 21 years.
a) State the null and alternative hypotheses.
b) If possible, perform a test. [Pick one of the options (A)-(D).]
ADDITIONAL PRACTICE FOR THE FINAL
In the following problems you will be asked to choose one of the four options (A)-(D). The options are stated here once and for all. If you pick any option other than (A), you must fill in all blanks correctly for credit. Use the 5% cutoff for P.
(A) The question cannot be answered based on the information given.
(B) one-sample $z$ = ( ); P approx ( ); Conclusion: ( ).
(C) two-sample $z$ = ( ); P approx ( ); Conclusion: ( ).
(D) one-sample $t$ = ( ); d.f. = ( ); P approx ( ); Conclusion: ( ).
PROBLEM 1
A die is rolled 600 times. The face with six spots comes up 126 times. Does the die land "six" with chance 1/6? Or are there too many sixes? Answer the question in the following steps:
a) State the null hypothesis.
b) State the alternative hypothesis.
c) Under the null hypothesis, the number of sixes in the 600 rolls is expected to be ( ), give or take ( ).
d) In this context, pick one of the options (A)-(D).
Solution
a) Null $H_0: p = \frac{1}{6}$
b) Alternative $H_A: p >\frac{1}{6}$
c) $$E=n\cdot p=600\times\frac{1}{6}=100$$ $$\sigma=\sqrt{p\cdot(1-p)\cdot n}=\sqrt{\frac{1}{6}\times\frac{5}{6}\times600}=9.128709$$
d) This is one-sample $z$ test, (B) is correct. $$z=\frac{126-100}{\sigma}$$ and P-value is 0.002198659 which is smaller than 0.05, so we reject $H_0$. Thus the conclusion is $p > \frac{1}{6}$. R code:
sigma = sqrt(1/6 * 5/6 * 600) z = (126 - 100) / sigma 1 - pnorm(z) [1] 0.002198659PROBLEM 2
A simple random sample of 6 students is taken from among all students in a university. The average age of the sampled students is 20 years with an SD of 3 years. Someone wants to test the hypothesis that the average age of students in the university is 21 years.
a) State the null and alternative hypotheses.
b) If possible, perform a test. [Pick one of the options (A)-(D).]
BerkeleyX Stat2.3x Inference Notes: Section 5 Window to a Wider World
Full Solution Manual of PDF Format
[Lecture5.1 PDF]
[Lecture5.2 PDF]
[Lecture5.3 PDF]
Basic Formula:
Chi-square test
[Lecture5.1 PDF]
[Lecture5.2 PDF]
[Lecture5.3 PDF]
Basic Formula:
Chi-square test
- Random sample or not / Good or bad
- $$H_0: \text{Good model}$$ $$H_A: \text{Not good model}$$
- Based on the expected proportion to calculate the expected values
- $\chi^2$ statistic is $$\chi^2=\sum{\frac{(o-e)^2}{e}}$$ where $o$ is observed values, $e$ is expected values.
- The degree of freedom is the number of categories minus one
- Follows approximately the $\chi^2$ distribution, we can calculate its P-value by using R function:
1-pchisq(chi, df)
- Independent or not
- $$H_0: \text{Independent}$$ $$H_A: \text{not Independent}$$
- Contingency table
- Under $H_0$, in each cell of the table $$\text{expected count}=\frac{\text{row total}\times\text{column total}}{\text{grand total}}$$ That is, $P(A\cap B)=P(A)\cdot P(B)$ under the independent assumption.
- $\chi^2$ statistic is $$\chi^2=\sum{\frac{(o-e)^2}{e}}$$ where $o$ is observed values, $e$ is expected values.
- The degree of freedom is $(\text{row}-1)\times(\text{column}-1)$
- Follows approximately the $\chi^2$ distribution, we can calculate its P-value by using R function:
1-pchisq(chi, df)
Bayes' Rule Examples
Bayes' Rule
$$P(\theta|D, M)=\frac{P(D|\theta, M)\cdot P(\theta, M)}{P(D|M)}$$ where
$$P(\theta|D, M)=\frac{P(D|\theta, M)\cdot P(\theta, M)}{P(D|M)}$$ where
- $\theta$ is the parameter values.
- $D$ is the data values.
- $M$ is the model structure.
- $P(\theta|D, M)$ is the posterior probability, which is the strength of our belief in $\theta$ generated by the model $M$ when the data $D$ have been taken into account.
- $P(D|\theta, M)$ is the likelihood, which is the probability that the data could be generated by the model $M$ with parameter values $\theta$.
- $P(\theta, M)$ is the prior probability, which is the strength of our belief in $\theta$ generated by the model $M$ without the data $D$.
- $P(D|M)$ is the evidence, which is the probability of the data according to the model $M$, determined by summing across all possible parameter values $\theta$ (i.e. likelihood) weighted by the strength of belief in those parameter values (i.e. prior). Particularly,
- For discrete variables $$P(D|M)=\sum_{\theta}P(D|\theta, M)\cdot P(\theta, M)$$
- For continuous variables $$P(D|M)=\int_{\theta}P(D|\theta, M)\cdot P(\theta, M)\ d\theta$$
Plot Normal Distribution Density in R
The mathematical formula for the normal distribution density has two parameters: $\mu, \sigma$: $$p(x)=\frac{1}{\sqrt{2\pi}\cdot\sigma}e^{-\frac{1}{2}\cdot(\frac{x-\mu}{\sigma})^2}$$ where $\mu$ is the mean of the distribution and $\sigma$ is the standard deviation.
In order to plot the graph, we use the following way:
R code:
In order to plot the graph, we use the following way:
- Divide x-axis into small intervals, with width denoted $\Delta x$.
- The integral of the normal density is approximated by summing the masses of all the tiny intervals.
R code:
Simulating many flips of a fair coin in R
When we toss a fair coin, the result might be: $$H, H, T, H, T, \ldots$$ The proportion of the heads is $1, 1, \frac{2}{3}, 0.75, 0.6, \ldots$. We hope to simulate this process by using R. The $x$-axis is plotted on a logarithmic scale ($N=5000$ in the following example). Furthermore, we can set the probability of H when we are tossing a biased coin.
R code:
R code:
BerkeleyX Stat2.3x Inference Notes: Section 4 Dependent Samples
Full Solution Manual of PDF Format
[Lecture4.1 PDF]
[Lecture4.2 PDF]
[Lecture4.3 PDF]
[Lecture4.4 PDF]
Basic Formula:
Dependent Variables (paired samples)
ADDITIONAL PRACTICE PROBLEMS FOR EXERCISE SET 4
PROBLEM 1
To see whether caffeine affects the speed at which mice can run to a "reward", a simple random sample of 50 mice was taken from a large population of mice. Each mouse ran twice; once before the caffeine, and once after. The "before" run times had a mean of 32 seconds and an SD of 3 seconds. The "after" run times had a mean of 30 seconds and an SD of 3.5 seconds. The correlation between the "before" and "after" run times was 0.7. For 32 of the 50 mice, the "after" run time was shorter than the "before". Which of the following is a correct $z$ statistic to test whether mice in this population run faster after caffeine? More than one answer might be correct.
a) $(2 - 0) / \sqrt{0.424^2 + 0.495^2}$
b) $(2 - 0) / 0.362$
c) $(31.5 - 25) / 3.535$
[Lecture4.1 PDF]
[Lecture4.2 PDF]
[Lecture4.3 PDF]
[Lecture4.4 PDF]
Basic Formula:
Dependent Variables (paired samples)
- SD of the difference is $$\sqrt{\sigma_x^2+\sigma_y^2-2\cdot r\cdot\sigma_x\cdot\sigma_y}$$ where $r$ is the correlation between the two variables X and Y.
- Correlation $$r=\frac{1}{n}\cdot\sum_{i=1}^{n}(\frac{x_i-\bar{x}}{\sigma_x}\cdot\frac{y_i-\bar{y}}{\sigma_y})$$ where $$\sigma_x=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(x_i-\bar{x})^2}$$ $$\sigma_y=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_i-\bar{y})^2}$$ R function:
cor(x, y)
ADDITIONAL PRACTICE PROBLEMS FOR EXERCISE SET 4
PROBLEM 1
To see whether caffeine affects the speed at which mice can run to a "reward", a simple random sample of 50 mice was taken from a large population of mice. Each mouse ran twice; once before the caffeine, and once after. The "before" run times had a mean of 32 seconds and an SD of 3 seconds. The "after" run times had a mean of 30 seconds and an SD of 3.5 seconds. The correlation between the "before" and "after" run times was 0.7. For 32 of the 50 mice, the "after" run time was shorter than the "before". Which of the following is a correct $z$ statistic to test whether mice in this population run faster after caffeine? More than one answer might be correct.
a) $(2 - 0) / \sqrt{0.424^2 + 0.495^2}$
b) $(2 - 0) / 0.362$
c) $(31.5 - 25) / 3.535$
BerkeleyX Stat2.3x Inference Notes: Section 3 One-sample and two-sample tests
Full Solution Manual of PDF Format
[Lecture3.1 PDF]
[Lecture3.2 PDF]
[Lecture3.3 PDF]
[Lecture3.4 PDF]
Basic Formula:
[Lecture3.1 PDF]
[Lecture3.2 PDF]
[Lecture3.3 PDF]
[Lecture3.4 PDF]
Basic Formula:
- One-sample $t$ test
- Test for a population mean (unknown SD); sample size $n$. That is, known sample mean and SD but unknown population mean (needs to be tested) and SD.
- Same $H_0$ and $H_A$, same calculation as $z$ test, except:
- Assume population distribution roughly normal, unknown mean and SD.
- Approximate unknown SD of population by sample SD, with $n-1$ degree of freedom (i.e. denominator).
- Two independent samples
- Comparing the means
- Known parameters: $\mu$, $n$ and $\sigma$ (SD) of the independent samples.
- $H_0: \mu_1=\mu_2\Rightarrow$ the difference between the two sample means is expected to be $\mu_1-\mu_2$.
- The SE of the difference is $$SE_1=\frac{\sigma_1}{\sqrt{n_1}},\ SE_2=\frac{\sigma_2}{\sqrt{n_2}}$$ $$\Rightarrow SE=\sqrt{SE_1^2+SE_2^2}$$ \item The above result derives from $$SE(X-Y)=\sqrt{Var(X-Y)}$$ $$=\sqrt{1^2\cdot Var(X)+(-1)^2\cdot Var(Y)}=\sqrt{SE^2(X)+SE^2(Y)}$$
- $z$ statistics is $$z=\frac{\mu_1-\mu_2}{SE}$$
- Comparing the percents
- Known parameters: $p$ and $n$ of the independent samples
- $H_0: p_1=p_2$
- It should use the same percents estimation for both samples (i.e. pooled estimate), since the P-valuse is computed under the null $H_0: p_1=p_2$.
- Pooled estimate of $p$: $$\hat{p}=\frac{n_1\cdot p_1+n_2\cdot p_2}{n_1+n_2}$$
- SE of the sample proportion, for the two samples: $$SE_1=\sqrt{\frac{\hat{p}\cdot(1-\hat{p})}{n_1}}, SE_2=\sqrt{\frac{\hat{p}\cdot(1-\hat{p})}{n_2}}$$
- Similar to the sample mean, the SE of the difference between the sample percents is approximately $$SE=\sqrt{SE_1^2+SE_2^2}$$
- $z$ statistic is $$z=\frac{p_1-p_2}{SE}$$
- Comparing the means
BerkeleyX Stat2.3x Inference Notes: Section 2 Testing Statistical Hypotheses
Full Solution Manual of PDF Format
[Lecture2.1 PDF]
[Lecture2.2 PDF]
[Lecture2.3 PDF]
[Lecture2.4 PDF]
Basic Formula:
ADDITIONAL PRACTICE PROBLEMS FOR EXERCISE SET 2
PROBLEM 1
To test whether “red” comes up 18/38 of the time in spins of a roulette wheel, the wheel is spun 3800 times; the result is “red” 1720 times. Is the wheel biased against “red”? Answer the question in the following steps:
a) Formulate null and alternative hypotheses about p, the chance with which the wheel shows “red”. b) Calculate an exact P-value or its normal approximation.
c) State the conclusion of the test.
Solution
a) $$\text{Null}: p=\frac{18}{38}$$ $$\text{Alternative}: p < \frac{18}{38}$$ b) Binomial distribution (exact) $n=3800, p=\frac{18}{38}, k=0:1720$: $$P(p < \frac{18}{38})=\sum_{k=0}^{1720}C_{3800}^{k}\cdot p^k\cdot(1-p)^{3800-k}=0.004871166$$R code:
[Lecture2.1 PDF]
[Lecture2.2 PDF]
[Lecture2.3 PDF]
[Lecture2.4 PDF]
Basic Formula:
- Test of Hypotheses
$$\text{Null}: H_0$$ $$\text{Alternative}: H_A$$ Assuming the null is true, the chance of getting data like the data in the sample or even more like the alternative: P-value. If $P$ is small (i.e. cutoff), choose the alternative. Otherwise, stay with the null. - Significance Level and Power
- Significance level is the probability, under $H_0$, that the test concludes $H_A$ error probability, should be small.
- Power is the probability, under $H_A$, that the test concludes $H_A$ probability of correct conclusion, should be large.
ADDITIONAL PRACTICE PROBLEMS FOR EXERCISE SET 2
PROBLEM 1
To test whether “red” comes up 18/38 of the time in spins of a roulette wheel, the wheel is spun 3800 times; the result is “red” 1720 times. Is the wheel biased against “red”? Answer the question in the following steps:
a) Formulate null and alternative hypotheses about p, the chance with which the wheel shows “red”. b) Calculate an exact P-value or its normal approximation.
c) State the conclusion of the test.
Solution
a) $$\text{Null}: p=\frac{18}{38}$$ $$\text{Alternative}: p < \frac{18}{38}$$ b) Binomial distribution (exact) $n=3800, p=\frac{18}{38}, k=0:1720$: $$P(p < \frac{18}{38})=\sum_{k=0}^{1720}C_{3800}^{k}\cdot p^k\cdot(1-p)^{3800-k}=0.004871166$$R code:
sum(dbinom(0:1720, 3800, 18/38)) [1] 0.004871166Normal distribution (approximate): $\mu=n\cdot p=1800, \sigma=\sqrt{n\cdot p\cdot(1-p)}$: $$Z=\frac{1720.5-\mu}{\sigma}\Rightarrow P(p < \frac{18}{38})=0.004898679$$ R code:
n = 3800; p = 18 / 38; mu = n * p; sigma = sqrt(n * p * (1 - p)) z = (1720.5 - mu) / sigma pnorm(z) [1] 0.004898679c) $P$ is very small so reject Null, that is, the wheel is biased against "red".
BerkeleyX Stat2.3x Inference Notes: Section 1 Estimating unknown parameters
Full Solution Manual of PDF Format
[Lecture_intro PDF]
[Lecture1.1 PDF]
[Lecture1.2 PDF]
[Lecture1.3 PDF]
[Lecture1.4 PDF]
Basic Formula:
[Lecture_intro PDF]
[Lecture1.1 PDF]
[Lecture1.2 PDF]
[Lecture1.3 PDF]
[Lecture1.4 PDF]
Basic Formula:
- Estimating population means and percents
Sampling assumptions:- Simple Random Sample (SRS)
- Large enough so that the probability histogram for the sample mean / percents is roughly normal, by Central Limit Theorem.
- Small enough relative to the population size that the correction factor is close to 1.
- Confidence Interval (CI)
$$\mu:\ \bar{X}\pm Z\cdot SE$$ $$p:\hat{p}\pm Z\cdot SE$$ where $\bar{X}, \mu$ are sample mean and population mean respectively, $\hat{p}, p$ are sample percents and population percents respectively. For calculating $Z$ can use R function, for instance, 90% CIz = qnorm((1 - 0.9) / 2)
BerkeleyX Stat2.2x Probability Notes: Final
[Stat2.2x Full Lecture PDF]
ADDITIONAL PRACTICE FOR THE FINAL
PROBLEM 1
A box contains 8 dark chocolates, 8 milk chocolates, and 8 white chocolates. (It’s amazing how this box keeps replenishing itself and reappearing. It’s like the Magic Pudding. Australians will know what I mean, and the rest of you might enjoy finding out. It’s one of the classics of children’s literature.)
A simple random sample of 6 chocolates is drawn. Find:
a) the expected number of dark chocolates
b) the SE of the number of dark chocolates
c) the chance that there are fewer than 2 dark chocolates
d) the chance that the second and third chocolates drawn are dark, given that the first and fourth chocolates drawn are not dark
e) the expected number of dark chocolates among the last four draws
Solution
This is hypergeometric distribution (Zeros and Ones: Sum of a sample without replacement), $n=6, N=24, G=8$.
1a) $$E(\text{dark chocolates})=n\cdot\frac{G}{N}=6\times\frac{8}{24}=2$$ 1b) $$SE(\text{dark chocolates})=\sqrt{n\cdot\frac{G}{N}\cdot\frac{N-G}{N}}\cdot\sqrt{\frac{N-n}{N-1}}$$ $$=\sqrt{6\times\frac{8}{24}\times\frac{16}{24}}\times\sqrt{\frac{24-6}{24-1}}\doteq1.021508$$ 1c) $$P(\text{fewer than 2 dark chocolates})=\sum_{x=0}^{1}\frac{C_{G}^{x}\cdot C_{N-G}^{n-x}}{C_{N}^{n}}$$ $$=\sum_{x=0}^{1}\frac{C_{8}^{x}\times C_{16}^{6-x}}{C_{24}^{6}}\doteq0.319118$$ R code:
ADDITIONAL PRACTICE FOR THE FINAL
PROBLEM 1
A box contains 8 dark chocolates, 8 milk chocolates, and 8 white chocolates. (It’s amazing how this box keeps replenishing itself and reappearing. It’s like the Magic Pudding. Australians will know what I mean, and the rest of you might enjoy finding out. It’s one of the classics of children’s literature.)
A simple random sample of 6 chocolates is drawn. Find:
a) the expected number of dark chocolates
b) the SE of the number of dark chocolates
c) the chance that there are fewer than 2 dark chocolates
d) the chance that the second and third chocolates drawn are dark, given that the first and fourth chocolates drawn are not dark
e) the expected number of dark chocolates among the last four draws
Solution
This is hypergeometric distribution (Zeros and Ones: Sum of a sample without replacement), $n=6, N=24, G=8$.
1a) $$E(\text{dark chocolates})=n\cdot\frac{G}{N}=6\times\frac{8}{24}=2$$ 1b) $$SE(\text{dark chocolates})=\sqrt{n\cdot\frac{G}{N}\cdot\frac{N-G}{N}}\cdot\sqrt{\frac{N-n}{N-1}}$$ $$=\sqrt{6\times\frac{8}{24}\times\frac{16}{24}}\times\sqrt{\frac{24-6}{24-1}}\doteq1.021508$$ 1c) $$P(\text{fewer than 2 dark chocolates})=\sum_{x=0}^{1}\frac{C_{G}^{x}\cdot C_{N-G}^{n-x}}{C_{N}^{n}}$$ $$=\sum_{x=0}^{1}\frac{C_{8}^{x}\times C_{16}^{6-x}}{C_{24}^{6}}\doteq0.319118$$ R code:
sum(dhyper(0:1, 8, 16, 6)) [1] 0.3191181d) $$P(\text{2nd and 3rd are dark | 1st and 4th are not dark})$$ $$=\frac{8}{22}\times\frac{7}{21}\doteq0.1212121$$ 1e) Given no information about any other draw, the last four draws are probabilistically the same as any other four, say the first four. $$E(\text{dark chocolates among the last four draws})=4\times\frac{8}{24}\doteq1.333333$$
BerkeleyX Stat2.2x Probability Notes: Section 5 The accuracy of simple random samples
[Lecture5.1 PDF]
[Lecture5.2 PDF]
[Lecture5.3 PDF]
[Section 3-5 Summary PDF]
Basic Formula:
[Lecture5.2 PDF]
[Lecture5.3 PDF]
[Section 3-5 Summary PDF]
Basic Formula:
- Zeros and Ones: Sum of a sample with replacement
$S$ is the number of successes: $n$ independent trials, chance of success on a single trial is $p$
$$E(S)=n\cdot p,\ SE(S)=\sqrt{n\cdot p\cdot(1-p)}$$ Binomial formula: $$P(S=k)=C_{n}^{k}\cdot p^{k}\cdot(1-p)^{n-k}$$ where $k=0, 1, 2, \ldots, n$. R code:
dbinom(x = k, size = n, prob = p)
- Zeros and Ones: Sum of a sample without replacement
$S$ is the number of good elements in a simple random sample: $n$ elements drawn from $N=G+B$ elements of which $G$ are good.
$$E(S)=n\cdot\frac{G}{N},\ SE(S)=\sqrt{n\cdot\frac{G}{N}\cdot\frac{B}{N}}\cdot\sqrt{\frac{N-n}{N-1}}$$ Hypergeometric formula: $$P(S=g)=\frac{C_{G}^{g}\cdot C_{B}^{n-g}}{C_{N}^{n}}$$ where $g$ is the number of good elements in the sample. R code:
dhyper(k = n, m = G, n = B, x = g)
- Zeros and Ones: Sample proportion of ones
$n$ is the sample size, $X$ is the sample proportion of ones.
Binomial setting: $$E(X)=p,\ SE(X)=\sqrt{\frac{p\cdot(1-p)}{n}}$$ Hypergeometric setting: $$E(X)=\frac{G}{N},\ SE(X)=\sqrt{\frac{\frac{G}{N}\cdot\frac{B}{N}}{n}}\cdot\sqrt{\frac{N-n}{N-1}}$$ - Sample sum
Population mean is $\mu$, $SD$ is $\sigma$, sample size is $n$, sample sum is $S$, and population size is $N$.
With replacement:
$$E(S)=n\cdot\mu,\ SE(S)=\sqrt{n}\cdot\sigma$$ Without replacement: $$E(S)=n\cdot\mu,\ SE(S)=\sqrt{n}\cdot\sigma\cdot\sqrt{\frac{N-n}{N-1}}$$ - Sample mean
Population mean is $\mu$, $SD$ is $\sigma$, sample size is $n$, sample mean is $M$, and population size is $N$.
With replacement:
$$E(M)=\mu,\ SE(M)=\frac{\sigma}{\sqrt{n}}$$ Without replacement: $$E(M)=\mu,\ SE(M)=\frac{\sigma}{\sqrt{n}}\cdot\sqrt{\frac{N-n}{N-1}}$$ - Square Root Law
If you multiple the sample size by a factor, the accuracy goes up by the square root of the factor.
BerkeleyX Stat2.2x Probability Notes: Section 4 The Central Limit Theorem
[Lecture4.1 PDF]
[Lecture4.2 PDF]
[Lecture4.3 PDF]
[Lecture4.4 PDF]
[Lecture4.5 PDF]
Basic Formula:
[Lecture4.2 PDF]
[Lecture4.3 PDF]
[Lecture4.4 PDF]
[Lecture4.5 PDF]
Basic Formula:
- Standard Error
The standard error of a random variable $X$ is defined by $$SE(X)=\sqrt{E((X-E(X))^2)}$$ $SE$ measures the rough size of the chance error in $X$: roughly how far off $X$ is from $E(X)$. - Standard Deviation
The standard deviation of a list of numbers is $$SD=\sqrt{E((x-\mu)^2)}$$ where $\mu=E(x)$. $SD$ measures the rough size of the deviations: roughly how far off the numbers are from the average. - $SE$ of the Sum of the Draws
$n$ draws at random with replacement from a box of numbered tickets, the standard error of the sum of the draw is $$SE=\sqrt{\text{number of draws}}\cdot(SD\ \text{of the box})=\sqrt{n}\cdot\sigma$$ where $\sigma=\sqrt{E((x-\mu)^2)}$ - Chebychev's Inequality
The probability that $X$ is $k$ or more $SEs$ away from $E(X)$ is at most $\frac{1}{k^2}$, that is $$P(X\ \text{is outside the interval}\ E(X)\pm k\cdot SE(X))\leq\frac{1}{k^2}$$ For instance, $$P(X\ \text{is inside the interval}\ E(X)\pm2\cdot SE(X))\geq1-\frac{1}{2^2}=\frac{3}{4}$$ - De Moivre - Laplace Theorem
Fix any $p$ strictly between $0$ and $1$. As the number of trials $n$ increases, the probability histogram for the binomial distribution looks like the normal curve with mean $\mu=n\cdot p$ and $SD=\sqrt{n\cdot p\cdot(1-p)}$. - Central Limit Theorem
Let $X_1, X_2, \ldots, X_n$ be independent and identically distributed, each with expected value $\mu$ and standard error $\sigma$. Let $S_n=X_1+X_2+\ldots+X_n$. Then for large $n$, the probability distribution of $S_n$ is approximately normal with mean $n\mu$ and standard deviation $\sqrt{n}\sigma$, no matter what the distribution of each $X_i$. - Normal Approximation of Binomial Distribution $$\mu=n\cdot p, SE=\sqrt{n\cdot p\cdot(1-p)}$$ $$Z_1=\frac{X_1-\mu}{SE}, Z_2=\frac{X_2-\mu}{SE}$$ $$P(X_1\leq X\leq X_2)=\text{Area under the standard normal curve between}\ X_1,X_2 $$ R code:
mu = n * p; se = sqrt(n * p * (1 - p)) z1 = (x1 - mu) / se; z2 = (x2 - mu) / se pnorm(z2) - pnorm(z1)
BerkeleyX Stat2.2x Probability Notes: Section 3 The law of averages, and expected values
[Lecture3.1 PDF]
[Lecture3.2 PDF]
[Lecture3.3 PDF]
[Lecture3.4 PDF]
Basic Formula:
PRACTICE
PROBLEM 1
In each pair of events below, pick the one that has the higher chance.
1a) A: 50,000 heads in 100,000 tosses of a coin
B: 500,000 heads in 1,000,000 tosses of a coin
1b) A: In 60 rolls of a die, the number of times “six” shows up is in the range 10 plus or minus 3
B: In 600 rolls of a die, the number of times “six” shows up is in the range 100 plus or minus 3
1c) A: In 1000 draws by a random number generator, the percent of times “0” shows up is in the range 10% plus or minus 1%
B: In 10,000 draws by a random number generator, the percent of times “0” shows up is in the range 10% plus or minus 1%
1d) A: In 1000 draws by a random number generator, the percent of times “0” appears is less than 11%
B: In 10,000 draws by a random number generator, the percent of times “0” appears is less than 11%
[Lecture3.2 PDF]
[Lecture3.3 PDF]
[Lecture3.4 PDF]
Basic Formula:
- Law of Large Numbers As the number of trials increases, the chance that the proportion of successes is in the range $$p\pm\text{a fixed amount}$$ goes to $1$.
- Expected value of the Binomial If a random variable $X$ has the binomial distribution with parameters $n$ and $p$, then $$E(x)=n\cdot p$$
PRACTICE
PROBLEM 1
In each pair of events below, pick the one that has the higher chance.
1a) A: 50,000 heads in 100,000 tosses of a coin
B: 500,000 heads in 1,000,000 tosses of a coin
1b) A: In 60 rolls of a die, the number of times “six” shows up is in the range 10 plus or minus 3
B: In 600 rolls of a die, the number of times “six” shows up is in the range 100 plus or minus 3
1c) A: In 1000 draws by a random number generator, the percent of times “0” shows up is in the range 10% plus or minus 1%
B: In 10,000 draws by a random number generator, the percent of times “0” shows up is in the range 10% plus or minus 1%
1d) A: In 1000 draws by a random number generator, the percent of times “0” appears is less than 11%
B: In 10,000 draws by a random number generator, the percent of times “0” appears is less than 11%
订阅:
博文 (Atom)