In [13]:
import matplotlib.pyplot as plt
import pandas as pd
In [14]:
%run src/lg_model.py
In [15]:
lg = LinearGaussian()
In [16]:
a = lrm_analytic(lg)
In [17]:
a
Out[17]:
A figure showing approximation of stability exponent at different levels of discretization.
In [18]:
D_vals = np.arange(5, 250, step=5)
discrete_exponent_vals = np.empty_like(D_vals, dtype=np.float64)
In [19]:
for d, D in enumerate(D_vals):
discrete_exponent_vals[d] = lrm_discretized(lg, D=D)
In [20]:
fig, ax = plt.subplots()
ax.ticklabel_format(useOffset=False)
#ax.set_ylim((a - 1.5 * 1e-8, a + 2 * 1e-9))
ax.plot(D_vals, np.ones_like(D_vals) * a, label="true value")
ax.plot(D_vals, discrete_exponent_vals, label="discrete approximation")
ax.legend()
Out[20]:
In [ ]:
A table that compares discretized val vs actual value for different values of the parameters
In [21]:
lg.γ
Out[21]:
Preference params from SSY
In [22]:
β = 0.998
ψ = 1.5
In [23]:
D_vals = [5, 50, 100, 200]
gamma_vals = [7.5, 10, 12.5]
MC_table = np.empty((len(gamma_vals), len(D_vals) + 1))
Lambda_table = np.empty_like(MC_table)
In [24]:
for i, γ in enumerate(gamma_vals):
lg = LinearGaussian(γ=γ)
MC_table[i, 0] = lrm_analytic(lg)
Lambda_table[i, 0] = lg.β * MC_table[i, 0]**(1 - 1/lg.ψ)
for j, d in enumerate(D_vals):
MC_table[i, j+1] = round(lrm_discretized(lg, D=d), 7)
Lambda_table[i, j+1] = β * MC_table[i, j+1]**(1 - 1/ψ)
In [25]:
MC_table
Out[25]:
In [26]:
def make_table(table):
pd_table = pd.DataFrame(table)
print(pd_table.to_latex(float_format=lambda x: '%1.7f' % x))
In [27]:
make_table(MC_table)
In [28]:
make_table(Lambda_table)
In [29]:
gamma_vals
Out[29]:
In [32]:
lg = LinearGaussian(γ=1)
In [33]:
lrm_analytic(lg)
Out[33]:
In [ ]: