Chapter 9.3 Exercise 11:

1. 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 = \frac{1}{4}\). If \(Y_1 = 100\), estimate the probability that \(Y_{365}\) is:

To solve this, we’ll use the fact that the daily changes in the stock price are like a series of random steps with an average change of 0 and a bit of spread each day. Since we’re looking at the price after a whole year (365 days), these small daily changes add up, and the overall change behaves like a bell-shaped curve.

Starting at $100, we want to figure out the chances that the stock’s price will be at or above $100, $110, and $120 at the end of the year.

We’ll use R to do the math based on the properties of the bell curve.

# Parameters
mean_Y1 = 100  # Mean of Y1
variance = 365 * 1/4  # Total variance after 365 days

# Probabilities
prob_a = 1 - pnorm(100, mean = mean_Y1, sd = sqrt(variance))
prob_b = 1 - pnorm(110, mean = mean_Y1, sd = sqrt(variance))
prob_c = 1 - pnorm(120, mean = mean_Y1, sd = sqrt(variance))

# Results
prob_a  # Probability that Y365 >= 100
## [1] 0.5
prob_b  # Probability that Y365 >= 110
## [1] 0.1475849
prob_c  # Probability that Y365 >= 120
## [1] 0.01814355

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

library(numDeriv)

# Random parameters for the binomial distribution
n <- 10  # Number of trials
p <- 0.5  # Probability of success

# MGF of the binomial distribution
mgf <- function(t) { (1 - p + p * exp(t))^n }

# First derivative at t = 0 for expected value
mgf_first_derivative <- grad(mgf, 0)

# Second derivative at t = 0 for variance calculation
mgf_second_derivative <- hessian(mgf, 0)

# Expected value (E[X]) is the first derivative of MGF at t = 0
expected_value <- mgf_first_derivative

# Variance (Var(X)) is the second derivative of MGF at t = 0 minus the square of the first derivative
variance <- mgf_second_derivative - mgf_first_derivative^2


expected_value
## [1] 5
variance
##          [,1]
## [1,] 2.500006

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

library(Deriv)

# Random rate parameter for the exponential distribution
lambda <- 3 

# MGF of the exponential distribution
mgf <- function(t) { lambda / (lambda - t) }

# The first derivative of the MGF (for expected value)
mgf_first_derivative <- Deriv(mgf, "t")

# The second derivative of the MGF (for variance calculation)
mgf_second_derivative <- Deriv(mgf_first_derivative, "t")

# We evaluate the first derivative at t=0 to get the expected value
expected_value <- mgf_first_derivative(t=0)

# We evaluate the second derivative at t=0 and subtract the square of the expected value to get the variance
variance <- mgf_second_derivative(t=0) - expected_value^2

expected_value
## [1] 0.3333333
variance
## [1] 0.1111111