(on pg 363, q 11) The price of one share of stock in the Pilsdorff Beer Company (see Exercise 8.2.12) is given by Yn on the nth day of the year. Finn observes that the differences Xn = Yn+1 − Yn appear to be independent random variables with a common distribution having mean µ = 0 and variance σ2 = 1/4. If Y1 = 100, estimate the probability that Y365 is (a) ≥ 100. (b) ≥ 110. (c) ≥ 120.
#define given values
y_1 <- 100 #stock price on 1st day
mu <-0 #mean
variance <-1/4 #sd squared therefore SD is .5
n <- 364 #y_365 - Y_1 for the remaining time so looking for 364 days
y.var <- variance*n #answer is 91
y.sd <-sqrt(y.var)
z = (100 - y_1) / y.sd
pnorm(z, lower.tail=FALSE)
## [1] 0.5
1-pnorm((100-y_1)/y.sd) #confirming
## [1] 0.5
1-pnorm((110-y_1)/y.sd)
## [1] 0.1472537
1-pnorm((120-y_1)/y.sd)
## [1] 0.01801584
Calculate the expected value and variance of the binomial distribution using the moment generating function. The moment generating function (MGF) of the binomial: \[M_X(t) = (pe^t + 1 - p)^n\]
Formula for expected value: \[E(X) =
M_X'(0)\] First derivative \[M_X'(t) = npe^t(pe^t + 1 - p)^{n-1}\]
Plug in 0 for t: \[E(X) = M_X'(0) = n
\cdot p\]
Formula for variance: \[\text{Var}(X) = M_X''(0) - [M_X'(0)]^2\] Second derivative: \[M_X''(t) = npe^t[pe^t(n - 1 + 1) + 1 - p]^{n-2}\] Plug in t=0 \[\text{Var}(X) = M_X''(0) - [M_X'(0)]^2 = n \cdot p \cdot (1 - p)\]
#trying an example using (a) from number 1 I want to test this
n <- 364
p <- 0.5
# Calculate the variance
variance100 <- n * p * (1 - p)
variance100 #surpringly matches y.var
## [1] 91
Calculate the expected value and variance of the exponential distribution using the moment generating function.
MGF of the exponential distribution is: \[ f(x) = \lambda e^{-\lambda x} \] where lambda is can be defines as occurrences per unit of time \[ M_X(t) = \frac{\lambda}{\lambda - t} \quad \text{for} \quad t < \lambda\]
\[ M(t) = \int_0^\infty e^{tx} \lambda e^{-\lambda x} dx = \frac{\lambda}{\lambda - t}, \quad \text{for } t < \lambda \]
First Derivative \[M'(t) = \lambda \left(\frac{\lambda}{\lambda - t}\right)^2 \]
Plug in 0 \[ E(X) = M'(0) = \frac{\lambda}{\lambda - 0} = \frac{1}{\lambda} \] The expected value is \(\frac{1}{\lambda}\).
The variance of the continuous rv is calculated : \[ \text{Var}(X) = E(X^2) - [E(X)]^2 \]
Second Derivative ofr M(t) \[ E(X^2) = M''(t) = \int_0^\infty t^2 \lambda e^{-\lambda x} dx = \frac{2}{\lambda^2} \]
Therefore:
\[ \text{Var}(X) = \frac{2}{\lambda^2} - \left(\frac{1}{\lambda}\right)^2 = \frac{1}{\lambda^2} \]
Simplify to find variance is \(\frac{1}{\lambda^2}\).