Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import matplotlib.

pyplot as plt
import numpy as np

# Parameters
alpha = 0.3 # Example parameter value
beta = 0.9 # Example parameter value

# Define a grid for capital (or wealth) k


k = np.linspace(1, 10, 100)

# Define the functions based on your provided equations

# Value Function
def V(k, alpha, beta):
return (np.log(1-alpha*beta)/(1-beta) +
(alpha*beta*np.log(alpha*beta))/((1-alpha*beta)*(1-beta)) +
np.log(k**alpha)/(1-alpha*beta))

# Policy Function
def h(k, alpha, beta):
return beta*alpha*k**alpha

# Optimal Consumption
def c(k, alpha, beta):
return (1-beta*alpha)*k**alpha

# Create plots
plt.figure(figsize=(15, 5))

plt.subplot(1, 3, 1)
plt.plot(k, V(k, alpha, beta))
plt.title('Value Function')
plt.xlabel('k')
plt.ylabel('V(k)')

plt.subplot(1, 3, 2)
plt.plot(k, h(k, alpha, beta))
plt.title('Policy Function')
plt.xlabel('k')
plt.ylabel('h(k)')

plt.subplot(1, 3, 3)
plt.plot(k, c(k, alpha, beta))
plt.title('Optimal Consumption')
plt.xlabel('k')
plt.ylabel('c')

plt.tight_layout()
plt.show()

You might also like