預測因通膨而成長的支出
你也要假設每月支出因為通膨,每年平均上漲 2.5%。這代表生活成本會隨時間提高,你每年支付相同項目的費用,但價格更高。所幸你的薪資成長快於通膨,表示每個月應該有更多金額能投入儲蓄。
上一題的變數 monthly_expenses 與 forecast_months 已可使用。
本練習屬於課程
Python 金融概念入門
練習說明
- 將年度通膨率設為 2.5%。
- 推導等效的每月通膨率。
- 預測隨時間累積的通膨成長。
- 依通膨帶來的成長調整,推導你的每月支出。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
import numpy as np
# Set the annual inflation rate
annual_inflation = ____
# Calculate the equivalent monthly inflation rate
monthly_inflation = ____
# Forecast cumulative inflation over time
cumulative_inflation_forecast = ____
# Calculate your forecasted expenses
expenses_forecast = ____
# Plot the forecasted expenses
plt.plot(expenses_forecast, color='red')
plt.show()