Problem 1

Alternative solution to part a)

Define the random variable \(D = L - v\). Note that \(\mu_D = \mu_L - v\) and \(\sigma^2_D = \sigma^2_L\), by the basic properties of expectations and variance w.r.t. linear transformations. Also, by rearranging the shortcut formula for the variance of a random variable, \(\mathbb{E}[D^2] = \sigma^2_D + \mu^2_D\)

Then

\[ \mathbb{E}\left[-\left( L - v \right)^2 \right] = -\mathbb{E}[D^2] = -\left( \sigma^2_L + \left( \mu_L - v \right)^2 \right) \]

Problem 2

Parts d) - h) through simulation

We can generate draws from any random variable by inverting its CDF and inserting \(U[0, 1]\) draws. In this case, the CDF of \(X\) is \(F(x) = \frac{x^4}{625}\), so \(F^{-1}(u) = 5 \sqrt[4]{u}\):

# Generate a bunch of uniform random draws
uu = runif(1e6)

# Pass through F^{-1} to get draws of X:
xx = 5 * uu^.25

# Plot to demonstrate
par(las = 1L) #can't pass this to hist directly for some reason
hist(xx, probability = TRUE,
     xlab = expression(X),
     main = paste0("Histogram of Inverted Draws\n",
                   "vs. Known Density"))
lines(xxx <- seq(0, 5, length.out = 1000L),
      4/625 * xxx^3, lwd = 3L, col = "red")

Make sure you understand why the red line and the histogram come from completely different approaches, even though they line up perfectly! (as they should, if you know what’s going on intuitively)

Now that we have a bunch of draws from \(X\), it’s super easy to simulate its expectation, variance and median:

#d)
mean(xx)
## [1] 3.999312
var(xx)
## [1] 0.6672398
#e)
median(xx)
## [1] 4.204239
#f)
mean(xx == 3)
## [1] 0
#g)
mean(2 <= xx & xx <= 4)
## [1] 0.38427
#h)
mean(xx < 1 | xx > 4)
## [1] 0.591627

Problem 3

Part b)

#note that we have to use TWO on the
#  lower end, NOT three -- since
#  this is a discrete distribution,
#  the mass accumulated at 3 is
#  important.
diff(ppois(c(2, 15), 9))
## [1] 0.9717321
#alternatively, using the density directly:
sum(dpois(3:15, 9))
## [1] 0.9717321

Part c)

The full distribution is in general much more informative than just knowing two moments. As an illustration, here are a bunch of distributions that have the same mean and variance as mentioned in part a). This is by no means exhaustive:

xx = seq(0, 18, length.out = 1000L)
#can only plot integers for discrete distributions
xx.int = 0L:18L
plot(xx.int, dpois(xx.int, lambda = 9), type = "b", xlab = "",
     lwd = 3L, las = 1L, ylab = "probability/density", ylim = c(0, .3),
     main = "Some Distributions with Mean & Variance 9")
lines(xx, dnorm(xx, mean = 9, sd = 3), col = "red")
lines(xx, dgamma(xx, shape = 9, scale = 1), col = "blue")
lines(xx, dlnorm(xx, meanlog = .5*log(729/10),
                 sdlog = sqrt(log(10/9))), col = "darkgreen")
lines(xx, dlogis(xx, location = 9, scale = sqrt(27)/pi), col = "orange")
lines(xx, .3*dnorm(xx, mean = 2, sd = sqrt(900/58)) + 
        .7*dnorm(xx, mean = 84/7, sd = sqrt(900/58)), col = "purple")
lines(xx + 9 - 5.5087/3.5087, df(xx, df1 = 2, df2 = 5.5087), col = "cyan")
legend("topright", lty = 1L, lwd = c(3L, rep(1L, 6L)),
       legend = c("Poisson", "Normal", "Gamma", "Log-Normal",
                  "Logistic", "Bi-Modal Normal", "F"),
       col = c("black", "red", "blue", "darkgreen",
               "orange", "purple", "cyan"))