Page 363 # 11

Solution

# create a function
prob_function <- function(x){
  year <- 365
  std_variance <- 1/14
  starting_value <- 100

  variance_year_round <- year * std_variance

  result <- pnorm(x - starting_value, mean = 0, sd = sqrt(variance_year_round),lower.tail = FALSE)
}
# run function
a <- prob_function(100)
b <- prob_function(110)
c <- prob_function(120)

# print result
a
## [1] 0.5
b
## [1] 0.02508727
c
## [1] 4.483892e-05

Calculate the expected value and variance of the binomial distribution using the moment generating function.

Binominal Distribution

\[P(n,p) = \frac{n!}{x!(n-x)!}p^xq^{n-x}\]

Moment Generating function

\[M_{x}(t) = \sum_{x=0}^{n}e^{xt}\frac{n!}{x!(n-x)!}p^xq^{n-x}\]

\[M_{x}(t) = \sum_{x=0}^{n}(pe^t)^{x}\frac{n!}{x!(n-x)!}p^xq^{n-x}\]

\[M_{x}(t) = \sum_{x=0}^{n}(pe^t)^{x}\frac{n!}{x!(n-x)!}p^xq^{n-x}\]

\[M_{x}(t) = (pe^t + q)^n\]

Expected Value

\[M_{x}^{'}(t) = n(pe^t)(q + pe^t)^{n-1}\]

\[M_{x}^{'}(0) = n(pe^0)(q + pe^0)^{n-1}\]

\[M_{x}^{'}(0) = np(q + p)^{n-1} = np\]

Variance

\[M_{x}^{''}(t) = (npe^t)[(q + pe^t)^{n-2}(pe^t)] + [n(pe^t)(q + pe^t)^{n-1}]\]

\[M_{x}^{''}(t) = (npe^t)(q + pe^t)^{n-2} + [(n - 1)(pe^t) + (q + pe^t)]\]

\[M_{x}^{''}(t) = (npe^t)(q + pe^t)^{n-2} + [(n - 1)(pe^t) + (q + pe^t)]\]

\[M_{x}^{''}(t) = (npe^t)(q + pe^t)^{n-2} + [(npe^t - pe^t) + (q + pe^t)]\]

\[M_{x}^{''}(t) = (npe^t)(q + pe^t)^{n-2} + (npe^t + q)\]

\[M_{x}^{''}(0) = (npe^0)(q + pe^0)^{n-2} + (npe^0 + q) = np(q + np)\]

\[\sigma = M{''}(0) - M{'}(0)^2\]

\[\sigma = np(q + np) - (np)^2 = npq + n^2p^2 - n^2p^2 = npq\]

Calculate the expected value and variance of the exponential distribution using the moment generating function.

Exponential Distribution when x is greater than or equal to 0

\[f(x;\lambda) = \lambda e^{-\lambda x}\]

Moment Generating Function

\[M_{x}(t) = \int_{0}^{\infty} e^{tx} \lambda e^{-\lambda x}dx\]

\[M_{x}(t) = \lambda \int_{0}^{\infty} e^{tx-\lambda x}dx\]

\[M_{x}(t) = \lambda \int_{0}^{\infty} e^{x(t-\lambda)}dx\]

\[M_{x}(t) = \frac{\lambda}{t - \lambda}\]

Expected Value

\[M_{x}^{'}(t) = \frac{\lambda}{(t - \lambda)^2}\]

\[M_{x}^{'}(0) = \frac{\lambda}{(0 - \lambda)^2} = \frac{1}{-\lambda}\]

Variance

\[M_{x}^{''}(t) = \frac{2\lambda}{(t - \lambda)^3}\]

\[M_{x}^{''}(0) = \frac{2\lambda}{(0 - \lambda)^3} = \frac{2}{- \lambda^2}\]

\[\sigma = M{''}(0) - M{'}(0)^2\]

\[\sigma = \frac{2}{- \lambda^2}- (\frac{1}{-\lambda})^2 = \frac{1}{- \lambda^2}\]