@@ -48,7 +48,6 @@ Let's start with some standard imports:
4848
4949``` {code-cell} ipython3
5050import matplotlib.pyplot as plt
51- plt.rcParams["figure.figsize"] = (11, 5) # set default figure size
5251import quantecon as qe
5352import numpy as np
5453```
@@ -249,8 +248,6 @@ Hence we expect that $\hat p_n(x) \approx \psi^*(x)$ when $n$ is large.
249248The next figure shows convergence of $\hat p_n(x)$ to $\psi^* (x)$ when $x=1$ and
250249$X_0$ is either $0, 1$ or $2$.
251250
252- The figure shows convergence to the stationary distribution regardless of the
253- initial condition $X_0$.
254251
255252
256253``` {code-cell} ipython3
@@ -260,23 +257,23 @@ P = np.array([[0.971, 0.029, 0.000],
260257ts_length = 10_000
261258mc = qe.MarkovChain(P)
262259ψ_star = mc.stationary_distributions[0]
263- i = 1 # We study convergence to psi^*(x) when x = i
260+ x = 1 # We study convergence to psi^*(x)
264261
265262fig, ax = plt.subplots()
266- ax.axhline(ψ_star[i ], linestyle='dashed', color='black',
267- label = fr'$\psi^*({i })$')
263+ ax.axhline(ψ_star[x ], linestyle='dashed', color='black',
264+ label = fr'$\psi^*({x })$')
268265# Compute the fraction of time spent in state 0, starting from different x_0s
269266for x0 in range(3):
270267 X = mc.simulate(ts_length, init=x0)
271- p_hat = (X == i ).cumsum() / (1 + np.arange(ts_length))
272- ax.plot(p_hat, label=fr'$\psi^*({i })$ when $x_0 = \, {x0}$')
268+ p_hat = (X == x ).cumsum() / (1 + np.arange(ts_length))
269+ ax.plot(p_hat, label=fr'$\hat p_n({x })$ when $X_0 = \, {x0}$')
273270ax.set_xlabel('t')
274- ax.set_ylabel(fr'$\hat p_n({i })$')
271+ ax.set_ylabel(fr'$\hat p_n({x })$')
275272ax.legend()
276273plt.show()
277274```
278275
279- You might like to try changing $i =1$ to either $i =0$ or $i =2$.
276+ You might like to try changing $x =1$ to either $x =0$ or $x =2$.
280277
281278In any of these cases, ergodicity will hold.
282279
0 commit comments