開始使用免費開始

預測薪資成長與生活成本

由於通膨與累積經驗帶來的生產力提升,你的薪資可能會依工作而有不同的成長率。現在,因為你在需求持續成長的領域擔任 Data Scientist,可以假設你的年薪會隨表現逐年穩定成長。

你可以假設年薪成長率為 5%。也就是說,若你以每年 $85,000 起薪,15 年後每年可望超過 $176,000。稅後(假設稅率不變)約為每年 $125,000,對 Data Scientist 來說並不誇張。其實,你可能幾年內就能達到這個水準!但為了保守起見,你在預測時還是應該採取較審慎的假設。

在這個應用程式中,假設所有通膨與薪資成長都以每月的小幅調整發生,而不是在每年年底一次大幅調整。

上一個練習中的 monthly_takehome_salary 已可使用。

本練習屬於課程

Python 金融概念入門

檢視課程

練習說明

  • 推導等效的月薪成長率(公式請見提示!)。
  • 使用我們為你定義的 cumulative_salary_growth_forecast,推導你隨時間變化的實際薪資預測。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

import numpy as np

# Create monthly forecasts up to 15 years from now
forecast_months = 12*15

# Set your annual salary growth rate
annual_salary_growth = 0.05

# Calculate your equivalent monthly salary growth rate
monthly_salary_growth = ____

# Forecast the cumulative growth of your salary
cumulative_salary_growth_forecast = np.cumprod(np.repeat(1 + monthly_salary_growth, forecast_months))

# Calculate the actual salary forecast
salary_forecast = ____

# Plot the forecasted salary
plt.plot(salary_forecast, color='blue')
plt.show()
編輯並執行程式碼