mean <- 0
var <- 1/4
sd <- sqrt(var)
n <- 364
x <- 0/sqrt(n)
pnorm(x, mean, sd, lower.tail = FALSE)
## [1] 0.5
x <- 10/sqrt(n)
pnorm(x, mean, sd, lower.tail = FALSE)
## [1] 0.1472537
x <- 20/sqrt(n)
pnorm(x, mean, sd, lower.tail = FALSE)
## [1] 0.01801584
The binomial PMF is defined as \({n \choose x}p^xq^{n-x}\) so the moment generating function is:
\[ \begin{align} M(t) &= \sum_{x=0}^{n} e^{tx} {n \choose x}p^xq^{n-x} \\ &= \sum_{x=0}^{n} {n \choose x}(pe^t)^xq^{n-x} \\ & = (pe^t + q)^n \end{align} \]
To calculate the expected value using the moment generating function we take the first derivative of the MGF and then substitute 0 for t.
\[ M'(t) = n(pe^t + q)^{n-1}pe^t \\ E(X) = M'(0) = np \]
To calculate the variance using the moment generating function we take the second derivative of the MGF and then substitute 0 for t to find the second moment. Then we take the second moment minus the first moment squared to find the variance.
\[ M''(t) = n[1−p+pe^t]^{n−1}(pe^t)+(pe^t)n(n−1)[1−p+pe^t]^{n−2}(pe^t) \\ E(X^2) = M''(0) = n(n-1)p^2 + np \\ \begin{align} \\ Var(X) &= E(X^2) - E(X)^2 \\ &= n(n-1)p^2 + np - (np)^2 \\ &= (n^2p^2-1np^2) + np - (np)^2 \\ &= (np)^2-np^2 + np - (np)^2 \\ &= np - np^2 \\ &= np(1-p) \end{align} \]
The exponential PDF is defined as \(\lambda e^{−x \lambda}\) so the moment generating function is:
\[ \begin{align} M(t) &= \int_0^{\infty} e^{tx} \lambda e^{−x \lambda} dx \\ &= \lambda \int_0^{\infty} e^{-x(\lambda -t)} \\ &= -\lambda \frac{e^{-x(\lambda -t)}}{\lambda - t} \bigg\rvert _0^\infty \\ & = \frac{\lambda}{\lambda - t} \end{align} \]
To calculate the expected value using the moment generating function we take the first derivative of the MGF and then substitute 0 for t.
\[ M'(t) = \frac{\lambda}{(\lambda - t)^2} \\ E(X) = M'(0) = \frac{\lambda}{\lambda^2} = \frac{1}{\lambda} \]
To calculate the variance using the moment generating function we take the second derivative of the MGF and then substitute 0 for t to find the second moment. Then we take the second moment minus the first moment squared to find the variance.
\[ M''(t) = \frac{2\lambda}{(\lambda - t)^3} \\ E(X^2) = M''(0) = \frac{2\lambda}{\lambda^3} = \frac{2}{\lambda^2} \\ \begin{align} \\ Var(X) &= E(X^2) - E(X)^2 \\ &= \frac{2}{\lambda^2} - \frac{1}{\lambda^2} \\ &= \frac{1}{\lambda^2} \end{align} \]