The price of one share of stock in the Pilsdorff Beer Company 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
x_i <- 100 # Initial share price
x_t <- 100 # Target share price
n <- 365-1 # Number of days
mu <- 0
variance <- 1/4
sd <- sqrt(variance)
# Calculate z-score to standardize the change in share price
z <- (x_t-x_i)/(sd*sqrt(n))
# establish our density function
d <- function(x) {1/sqrt(2*pi)*exp(-x^2/2)}
# Find the area under the normal curve
a <- integrate(d, lower=z, upper=Inf)
# Probability that change in share price is >=0
a$value
## [1] 0.5
ANSWER: \(P(S_{364}\ge 0) =0.5\)
# Set variables
x_i <- 100 # Initial share price
x_t <- 110 # Target share price
n <- 365-1 # Number of days
mu <- 0
variance <- 1/4
sd <- sqrt(variance)
# Calculate z-score to standardize the change in share price
z <- (x_t-x_i)/(sd*sqrt(n))
# establish our probability density function
d <- function(x) {1/sqrt(2*pi)*exp(-x^2/2)}
# Find the area under the normal curve
b <- integrate(d, lower=z, upper=Inf)
# Probability that change in share price is >=10
b$value
## [1] 0.1472537
ANSWER: \(P(Y{365} \ge 110) = 0.1472537\)
x_i <- 100 # Initial share price
x_t <- 120 # Target share price
n <- 365-1 # Number of days
mu <- 0
variance <- 1/4
sd <- sqrt(variance)
# Calculate z-score to standardize the change in share price
z <- (x_t-x_i)/(sd*sqrt(n))
# establish our probability density function
d <- function(x) {1/sqrt(2*pi)*exp(-x^2/2)}
# Find the area under the normal curve from z to infinity
c <- integrate(d, lower=z, upper=Inf)
# Probability that change in share price is >=20
c$value
## [1] 0.01801584
ANSWER: \(P(Y{365} \ge 120) = 0.01801584\)
Please note that we can also use pnorm function to calculate the same probabilities.
Calculate the expected value and variance of the binomial distribution using the moment generating function.
Answer:
For binomial distribution, \(P(X=k) = {n \choose k} p^k q^{n-k}\), where \(q=1-p\).
The moment generating function is \(M_X(t)=(q+pe^t)^n\).
The first moment is \(M'_X(t) = n(q+pe^t)^{n-1}pe^t\).
The expected value is the first moment evaluated at \(t=0\): \[ \begin{split} E(X)=M'_X(0) &= n(q+pe^0)^{n-1}pe^0\\ &= n(q+p)^{n-1}p\\ &= np(1-p+p)^{n-1}\\ &= np1^{n-1}\\ &=np \end{split} \] The second moment is \(M''_X(t) = n(n-1)(q+pe^t)^{n-2}p^2 e^{2t}+n(q+pe^t)^{n-1}pe^t\).
Evaluate the second moment at \(t=0\): \[ \begin{split} E(X^2)=M''_X(0) &= n(n-1)(q+pe^0)^{n-2}p^2 e^0+n(q+pe^0)^{n-1}pe^0\\ &= n(n-1)(1-p+p)^{n-2}p^2+n(1-p+p)^{n-1}p\\ &= n(n-1)p^2+np \end{split} \] The variance is \(V(X)=E(X^2)-E(X)^2\): \[ \begin{split} V(X) &= n(n-1)p^2+np-n^2p^2 \\ &= np((n-1)p+1-np) \\ &= np(np-p+1-np) \\ &= np(1-p) \\ &= npq \end{split} \] We arrived at the known definitions for binomial distribution - \(E(X)=np\) and \(V(X)=npq\).
Calculate the expected value and variance of the exponential distribution using the moment generating function.
Answer:
For exponential distribution, \(f(x)=\lambda e^{-\lambda x}\).
The moment generating function is \(M_X(t)=\frac{\lambda}{\lambda-t}, t<\lambda\).
Deriving, we get \(M'_X(t) = \frac{\lambda}{(\lambda-t)^2}\) and \(M''_X(t) = \frac{2\lambda}{(\lambda-t)^3}\).
Expected value is: \[ \begin{split} E(X)=M'_X(0) &= \frac{\lambda}{(\lambda-0)^2} \\ &= \frac{\lambda}{\lambda^2}\\ &= \frac{1}{\lambda} \end{split} \] Variance is: \[ \begin{split} V(X) = E(X^2)-E(X)^2 &= M''_X(0)-M'_X(0)^2 \\ &=\frac{2\lambda}{(\lambda-0)^3} - \frac{1}{\lambda^2}\\ &=\frac{2\lambda}{\lambda^3} - \frac{1}{\lambda^2}\\ &=\frac{2}{\lambda^2} - \frac{1}{\lambda^2}\\ &=\frac{1}{\lambda^2} \end{split} \] In conclusion, We get the definitions for binomial distribution: \(E(X)=1/\lambda\) and \(V(X)=1/\lambda^2\).