8. Expected Value and Standard Deviation of Bond Payments. You have a portfolio of 100 bonds. Each bond defaults with a probability of 0.07. If a bond defaults, it pays $0 at the end of one year. Otherwise, it repays $1.10. In this exercise, you'll compute the expected value and standard deviation of the total payment to the bond portfolio using the binomial distribution.
The expected value (E[X]) and standard deviation (σ) for a binomial distribution with parameters n
(number of trials) and p
(probability of success) are given by:
$$E[X] = n * p$$
$$\sigma = \sqrt{n * p * (1-p)}$$
Use the above formulas to compute the expected number of defaults and then derive the expected value and standard deviation of total payment.
# Define the number of bonds.
n_bonds <- ___
# Define the default probability.
p <- ___
# Compute expected number of defaults.
expected_defaults <- ___ * p
# Calculate the expected repayments.
expected_payment <- (n_bonds - ___) * 1.10
# Compute the standard deviation for number of defaults.
sd_defaults <- sqrt(n_bonds * p * (1-___))
# Convert to standard deviation of payment.
sd_payment <- ___ * 1.10
# Print the expected payment and standard deviation.
list(Expected_Payment = expected_payment, SD_Payment = sd_payment)
# Define the number of bonds.
n_bonds <- 100
# Define the default probability.
p <- 0.07
# Compute expected number of defaults.
expected_defaults <- n_bonds * p
# Calculate the expected repayments.
expected_payment <- (n_bonds - expected_defaults) * 1.10
# Compute the standard deviation for number of defaults.
sd_defaults <- sqrt(n_bonds * p * (1-p))
# Convert to standard deviation of payment.
sd_payment <- sd_defaults * 1.10
# Print the expected payment and standard deviation.
list(Expected_Payment = expected_payment, SD_Payment = sd_payment)
test_error()
test_object("n_bonds", incorrect_msg="Check the number of bonds.")
test_object("p", incorrect_msg="Check the default probability.")
test_object("expected_defaults", incorrect_msg="Check the formula for the expected number of defaults.")
test_object("expected_payment", incorrect_msg="Check the formula for the expected payment.")
test_object("sd_defaults", incorrect_msg="Check the formula for the standard deviation of defaults.")
test_object("sd_payment", incorrect_msg="Convert the standard deviation of defaults to repayments correctly.")
success_msg("Excellent work!")