1. Learn
  2. /
  3. Courses
  4. /
  5. Python for MATLAB Users

Exercise

Forecasting over time

In this exercise, you're going to use NumPy arrays to explore how an investment increases over 20 years. The forecast is calculated using the following formula:

\( balance = deposit (1 + rate)^{years} \)

You need to calculate and plot the percent gain on the investment for each month over 20 years, which is represented by the NumPy array years and has already been loaded into your workspace, along with the deposit and annual_rate of return. The calculation for percent gain is as follows:

\( gain = \dfrac{(balance-deposit)}{deposit}\times100\)

Instructions

100 XP
  • Forecast the balance in the account for each time point in the variable years.
  • Calculate the percent gain in the account.
  • Plot the percent gain as a function of years.