The price of one share of stock in the Pilsdorff Beer Company (see Exercise 8.2.12) is given by \(Y_n\) on the \(n^{th}\) day of the year. Finn observes that the differences \(X_n = Y_n+1 − Y_n\) appear to be independent random variables with a common distribution having mean \(\mu = 0\) and variance \(\sigma^2 = 1/4\). If \(Y_1 = 100\), estimate the probability that \(Y_{365}\) is
n <- 364
variance <- 1/4
mean <- 0
y1 <- 100
# sqrt(n*variance)
x <- sqrt(n*variance)
a<-100
result_a <- pnorm(a-y1,mean = mean, sd=sqrt(variance*n),lower.tail = FALSE)
print(result_a)
## [1] 0.5
b<-110
result_b<- pnorm(b-y1,mean = mean, sd=sqrt(variance*n),lower.tail=FALSE)
print(result_b)
## [1] 0.1472537
c<-120
result_c<-pnorm(c-y1,mean=mean,sd=sqrt(variance*n),lower.tail=FALSE)
print(result_c)
## [1] 0.01801584
Calculate the expected value and variance of the binomial distribution using the moment generating function.
\[ M_x(t) = \Sigma_{x=0}^n e^{xt} {n \choose k} p^x q^{n-x} \text{ where } q=1-p\\ = \Sigma_{x=0}^n (pe^t)^x {n\choose k} q^{n-x} = (q+pe^t)^n\\ \text{Differentiate with respect to t: }\\ \frac{dM_x(t)}{dt} (q+pe^t)^n = n(q+pe^t)^{n-1}pe^t\\ = npe^t(q+pe^t)^{n-1}\\ \text{Evaluate at t=0 to find } E[X]\\ E[X] = npe^t(q+pe^t)^{n-1}|_{t=0} = np\cdot (q+p)^{n-1}\\ = np(1-p+p)^{n-1}=np\\ E[X] = np\\ \text{To find the second moment:}\\ \frac{duv}{dx}=u\frac{dv}{dx}+v\frac{du}{dx}\\ \frac{d^2 M_x(t)}{dt^2}= npe^t(n-1)(q+pe^t)^{n-2}pe^t + npe^t(q+pe^t)^{n-1}\\ =npe^t(q+pe^t)^{n-2}{(n-e)pe^t}+(q+pe^t)\\ = npe^t(q+pe^t)^{n-2}(npe^t - pe^t + q + pe^t)\\ = npe^t(q+pe^t)^{n-2}(npe^t+q)\\ \text{Evaluate at t=0 to get } E[X^2]:\\ E[X^2] = np(q+p)^{n-2}(np+q)=np(np+q)\\ \text{To get the variance: } Var[X] = E[X^2] - (E[X])^2\\ Var[X] = np(np+q) - (np)^2 = n^2 p^2 + npq - n^2 p^2 = npq\\ Var[X] = npq\\ \text{In conclusion, } E[X] = np \text{ and } Var[X] = npq \]
Calculate the expected value and variance of the exponential distribution using the moment generating function.
\[ p_x(x) = \lambda e^{-\lambda x} \text{ where } x>0\\ M_x(t) = \int_{-\infty}^{\infty} xp_x(x)dx= \int_{-\infty}^{\infty} e^{tx}\lambda e^{-\lambda x} dx\\ =\int_{0}^{\infty} e^{tx}\lambda e^{-\lambda x}dx \text{ since } x>0\\ = \lambda \int_{0}^{\infty} e^{tx}e^{-\lambda x}dx = \lambda \int_{0}^{\infty} e^{tx - \lambda x}dx\\ = \lambda \int_{0}^{\infty} e^{x(t-\lambda)}xdx =\lambda [\frac{e^{x(t-\lambda)}}{t-\lambda}]_0^{\infty} =\frac{\lambda}{t-\lambda}\\ M_x(t) = \frac{\lambda}{\lambda - t}\\ \text{Find the first moment (E[X])}:\\ \frac{dM_x(t)}{dt}= \frac{d}{dt}(\frac{\lambda}{t-\lambda}) = \frac{\lambda}{(\lambda - t)^2}\\ \text{Evaluate at } t=0 \text{ to get } E[X]:\\ \frac{\lambda}{(\lambda-t)^2}|_{t=0} = \frac{\lambda}{\lambda^2} = \frac{1}{\lambda}\\ E[X] = \frac{1}{\lambda}\\ \text{Second moment of } E[X^2]: \\ \frac{d^2}{dt^2} M_x(t) = \frac{d}{dt^2} (\frac{\lambda}{\lambda - t}) = \frac{2\lambda}{(\lambda-t)^3}\\ \text{Evaluate at } t=0 \text{ to get } E[X^2]:\\ \frac{2\lambda}{(\lambda - t)^3}|_{t=0} = \frac{2\lambda}{\lambda^3} = \frac{2}{\lambda^2}\\ E[X^2] = \frac{2}{\lambda^2}\\ \text{Find the variance by solving: } Var[X] = E[X^2] - (E[X])^2:\\ Var[X] = \frac{2}{\lambda^2} - (\frac{1}{\lambda^2}) = \frac{2}{\lambda^2} - \frac{1}{\lambda ^2} =\frac{1}{\lambda^2}\\ \text{In conclusion, } E[X] = \frac{1}{\lambda}, Var[X] = \frac{1}{\lambda^2} \]