1.4 Discrete Random Variables
1.4.1 Bernoulli distribution
$ \mathbf{X}=\begin{cases} \begin{array}{lll} 1 & & ,\text{ if success}\\ 0 & & ,\text{ if fail.} \end{array}\end{cases} $
$ P\left(\left\{ \mathbf{X}=1\right\} \right)=p $.
$ P\left(\left\{ \mathbf{X}=0\right\} \right)=q\left(=1-p\right) $.
$ E\left[\mathbf{X}\right]=1\cdot P\left(\left\{ \mathbf{X}=1\right\} \right)+0\cdot P\left(\left\{ \mathbf{X}=0\right\} \right)=1\cdot p+0\cdot q=p $.
$ E\left[\mathbf{X}^{2}\right]=1^{2}\cdot P\left(\left\{ \mathbf{X}=1\right\} \right)+0^{2}\cdot P\left(\left\{ \mathbf{X}=0\right\} \right)=p $.
$ Var\left[\mathbf{X}\right]=E\left[\mathbf{X}^{2}\right]-\left(E\left[\mathbf{X}\right]\right)^{2}=p-p^{2}=p\left(1-p\right)=pq $.
Moment generating function
$ \phi_{\mathbf{X}}\left(s\right)=E\left[e^{s\mathbf{X}}\right]=e^{s\cdot1}\cdot p+e^{s\cdot0}\cdot q=p\cdot e^{s}+q $.
1.4.2 Binomial distribution
If $ \mathbf{Y}_{1},\mathbf{Y}_{2},\cdots $ are i.i.d. Bernoulli random variables, then Binomial random variable is defined as $ \mathbf{X}=\mathbf{Y}_{1}+\mathbf{Y}_{2}+\cdots+\mathbf{Y}_{n} $, which represents the number of success from $ n $ Bernoulli trials.
$ p_{\mathbf{X}}\left(k\right)=\left(\begin{array}{c} n\\ k \end{array}\right)p^{k}\left(1-p\right)^{n-k} $.
$ E\left[\mathbf{X}\right]=np $.
$ Var\left[\mathbf{X}\right]=np\left(1-p\right)=npq $.
Moment generating function
The moment generating function for Binomial distribution must be $ \phi_{\mathbf{X}}\left(s\right)=\left(p\cdot e^{s}+q\right)^{n} $ because Binomial distribution is the $ n $ convolution of Bernoulli distribution.
Check
$ \phi_{\mathbf{X}}\left(s\right)=E\left[e^{s\mathbf{X}}\right]=\sum_{k=0}^{n}e^{s\cdot k}\left(\begin{array}{c} n\\ k \end{array}\right)p^{k}\left(1-p\right)^{n-k}=\left(p\cdot e^{s}+\left(1-p\right)\right)^{n}=\left(p\cdot e^{s}+q\right)^{n}. $