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.
## set parameters
mu <- 0
sigma <- sqrt(1/4)
Y1 <- 100
n <- 365
## calculate mean and variance of Y365
mu_Y365 <- Y1
var_Y365 <- n * sigma^2
## calculate probabilities of interest using normal approximation
(a <- 1 - pnorm(100, mu_Y365, sqrt(var_Y365)))
## [1] 0.5
(b <- 1 - pnorm(110, mu_Y365, sqrt(var_Y365)))
## [1] 0.1475849
(c <- 1 - pnorm(120, mu_Y365, sqrt(var_Y365)))
## [1] 0.01814355
Calculate the expected value and variance of the binomial distribution using the moment generating function.
M(t) = E[e^(tX)] = (1 - p + pet)n Differentiate M(t) with respect to t and evaluate it at t=0 and t=0.5.
We have:
M’(t) = n(1 - p + pet)(n-1) * pe^t
Therefore, E(X) = M’(0) = n(1 - p + p)^n * p = np.
So the expected value of the binomial distribution is np.
Variance: We have:
M’’(t) = n(n-1)(1 - p + pet)(n-2) * p2e(2t) + n(1 - p + pet)(n-1) * pe^t
Therefore,
E(X^2) = M’‘(0) + M’(0) = n(n-1)(1 - p + p)^n * p^2 + np
= n(n-1)p^2 + np
And
Var(X) = E(X^2) - (E(X))^2
= n(n-1)p^2 + np - (np)^2
= np(1-p)
## set variables
n <- 10
p <- 0.3
## calculate MGF
t <- 0.5
MGF <- (1 - p + p * exp(t))^n
## calculate expected value and variance
Exp<- MGF * p * n
Exp
## [1] 17.75848
Var <- MGF * p * (1 - p) * n
Var
## [1] 12.43094
Calculate the expected value and variance of the exponential distribution using the moment generating function.
MGF:
M(t) = λ/(λ-t)
M’(t) = λ/((λ-t)^2)
Expected Value: M’(0) = 1/λ
M”(t) = 2λ/((λ-t)^3)
M”(0) = 2/(λ^2)
σ^2 = 2/(λ^2)- (1/λ)^2
= (1/λ)^2