무차별곡선 시각화하기
다음 효용 함수와 제약식이 주어졌습니다.
\(U(c, m)=c^{0.7}m^{0.3}\)
\(c+m=2\)
이를 활용해 무차별곡선을 시각화하세요.
np와 plt는 미리 로드되어 있어요.
이 연습은 강의의 일부입니다
Python으로 배우는 Optimization 입문
연습 안내
- 제약식을
m으로 정의하고,c와m의 조합을 생성하세요. - 효용 함수를 정의해
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()