開始使用免費開始

視覺化無異曲線

以下是提供給你的效用函式與限制條件:

\(U(c, m)=c^{0.7}m^{0.3}\)

\(c+m=2\)

請用這些資訊來視覺化無異曲線。

已為你載入 npplt

本練習屬於課程

Python 最佳化入門

檢視課程

練習說明

  • 將限制條件表示為 m,並產生 cm 的組合。
  • 定義效用函式並指定給 F
  • 繪製等高線與限制條件。

動手互動練習

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

c = np.linspace(1, 2, 10)  
# Define the constraint and generate combinations
m = ____
C, M = ____(c, m)
# Define the utility function
F = ____

plt.figure(figsize=(8, 6))
# Plot the controls and constraints
contours = ____(C, M, F, levels=[0.9, 1.00, 1.085, 1.2])
____(contours)
____(c, m, color='red')
plt.title('Indifference Curve with Constraint Line')
plt.xlabel('c')
plt.ylabel('m')
plt.grid(True)
plt.show()
編輯並執行程式碼