BaşlayınÜcretsiz Başlayın

Will the bank fail?

Plot the number of defaults you got from the previous exercise, in your namespace as n_defaults, as a CDF. The ecdf() function you wrote in the first chapter is available.

If interest rates are such that the bank will lose money if 10 or more of its loans are defaulted upon, what is the probability that the bank will lose money?

Bu egzersiz

Statistical Thinking in Python (Part 1)

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Compute the x and y values for the ECDF of n_defaults.
  • Plot the ECDF, making sure to label the axes. Remember to include marker = '.' and linestyle = 'none' in addition to x and y in your call plt.plot().
  • Show the plot.
  • Compute the total number of entries in your n_defaults array that were greater than or equal to 10. To do so, compute a boolean array that tells you whether a given entry of n_defaults is >= 10. Then sum all the entries in this array using np.sum(). For example, np.sum(n_defaults <= 5) would compute the number of defaults with 5 or fewer defaults.
  • The probability that the bank loses money is the fraction of n_defaults that are greater than or equal to 10. Print this result by hitting submit!

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Compute ECDF: x, y


# Plot the ECDF with labeled axes




# Show the plot


# Compute the number of 100-loan simulations with 10 or more defaults: n_lose_money


# Compute and print probability of losing money
print('Probability of losing money =', n_lose_money / len(n_defaults))
Kodu Düzenle ve Çalıştır