LoslegenKostenlos loslegen

Visualize the indifference curve

You have been provided the following utility function and constraint.

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

\(c+m=2\)

Use this to visualize the indifference curve.

np and plt have been loaded for you.

Diese Übung ist Teil des Kurses

Introduction to Optimization in Python

Kurs anzeigen

Anleitung zur Übung

  • Define the constraint as m and generate the combinations of c and m.
  • Define the utility function and assign it to F.
  • Plot the contours and constraint.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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()
Code bearbeiten und ausführen