使用 hexbin 圖的敏感度分析
你在前一個練習產生的模擬結果已儲存在 DataFrame df_sa 中,並且已為你載入。
回顧一下,df_sa 有 3 欄:Inflation 包含模擬中使用的平均通膨率,Volume 包含模擬中使用的平均銷售量,Profit 則是根據你的模擬所預測的利潤。
現在你要使用 hexbin 圖來進行敏感度分析,並了解這些參數的影響!
以下函式庫已為你匯入:pandas 作為 pd、numpy 作為 np、scipy.stats 作為 st,以及 matplotlib.pyplot 作為 plt。
本練習屬於課程
Python 的 Monte Carlo 模擬
練習說明
- 完成 hexbin 圖的程式碼,以視覺化敏感度分析結果;將
Inflation作為 x 軸、Volume作為 y 軸,並以Profits的「平均」值作為 hexbin 顏色的依據。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Complete the hexbin to visualize sensitivity analysis results
____(x=____,
y=____,
C=____,
reduce_C_function=____,
gridsize=10,
cmap="viridis",
sharex=False)
plt.show()