import numpy as np
import matplotlib.pyplot as plt

from ngm_discrete import NGM


T = np.array([[0.910507618836914, 0.089492259543859, 0.000000121619227],
    [0.028100505607270, 0.943798980953369, 0.028100513439361],
    [0.000000121619227, 0.089492259543859, 0.910507618836914]])
z = np.array([0.947938865630057, 1, 1.05492035009593])
chain = np.zeros([251, 500])

model = NGM(z=z)

for i, v in enumerate(z):
    model.ngm(attr_num=i, z=v)

fig = model.gen_plots(model.value_function[0], model.policy_rule[0])
model.gen_plots(model.value_function[1], model.policy_rule[1], fig=fig)
model.gen_plots(model.value_function[2], model.policy_rule[2], fig=fig)
plt.draw()
Esempio n. 2
0
# Policy Rule for labor (analytically)
# h = (theta -  theta * alpha) / (1 - beta * alpha + beta *
#                                 alpha * theta - theta * alpha)

theta = 44 / 121
k_l, k_u, k_n = 0.02, 0.08, 200

T = np.array([[0.5, 0.5], [0.5, 0.5]])
z = np.array([np.exp(-0.02,), np.exp(0.02)])


def u(c, h=h, theta=theta):
    return theta * np.log(c) + (1 - theta) * np.log(1 - h)


def f(k, h=h, alpha=alpha):
    return k ** alpha * h ** (1 - alpha)


stoch = Stochastic(z, T)

model = NGM(k_u=1, z=stoch, k_n=k_n)
vf, pr = model.ngm()


fig = model.gen_plots(vf[:, 0], pr[:, 0])
fig = model.gen_plots(vf[:, 1], pr[:, 1], fig=fig)

plt.draw()