@@ -3,8 +3,10 @@ jupytext:
33 text_representation :
44 extension : .md
55 format_name : myst
6+ format_version : 0.13
7+ jupytext_version : 1.16.7
68kernelspec :
7- display_name : Python 3
9+ display_name : Python 3 (ipykernel)
810 language : python
911 name : python3
1012---
@@ -33,10 +35,9 @@ kernelspec:
3335
3436In addition to what's in Anaconda, this lecture will need the following libraries:
3537
36- ``` {code-cell} ipython
37- ---
38- tags: [hide-output]
39- ---
38+ ``` {code-cell} ipython3
39+ :tags: [hide-output]
40+
4041!pip install quantecon
4142```
4243
@@ -65,9 +66,8 @@ Its many applications include:
6566
6667Let's start with some imports:
6768
68- ``` {code-cell} ipython
69+ ``` {code-cell} ipython3
6970import matplotlib.pyplot as plt
70- plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
7171import numpy as np
7272from quantecon import LinearStateSpace
7373from scipy.stats import norm
@@ -186,7 +186,8 @@ You can confirm that under these definitions, {eq}`st_space_rep` and {eq}`st_ex_
186186The next figure shows the dynamics of this process when $\phi_0 = 1.1, \phi_1=0.8, \phi_2 = -0.8, y_0 = y_ {-1} = 1$.
187187
188188(lss_sode_fig)=
189- ``` {code-cell} python3
189+
190+ ``` {code-cell} ipython3
190191def plot_lss(A,
191192 C,
192193 G,
@@ -205,7 +206,7 @@ def plot_lss(A,
205206 plt.show()
206207```
207208
208- ``` {code-cell} python3
209+ ``` {code-cell} ipython3
209210ϕ_0, ϕ_1, ϕ_2 = 1.1, 0.8, -0.8
210211
211212A = [[1, 0, 0 ],
@@ -269,7 +270,8 @@ y_{-3} = 1
269270$$
270271
271272(lss_uap_fig)=
272- ``` {code-cell} python3
273+
274+ ``` {code-cell} ipython3
273275ϕ_1, ϕ_2, ϕ_3, ϕ_4 = 0.5, -0.2, 0, 0.5
274276σ = 0.2
275277
@@ -651,7 +653,7 @@ The system in question is the univariate autoregressive model {eq}`eq_ar_rep`.
651653
652654The values of $y_T$ are represented by black dots in the left-hand figure
653655
654- ``` {code-cell} python3
656+ ``` {code-cell} ipython3
655657def cross_section_plot(A,
656658 C,
657659 G,
@@ -695,7 +697,7 @@ def cross_section_plot(A,
695697 plt.show()
696698```
697699
698- ``` {code-cell} python3
700+ ``` {code-cell} ipython3
699701ϕ_1, ϕ_2, ϕ_3, ϕ_4 = 0.5, -0.2, 0, 0.5
700702σ = 0.1
701703
@@ -716,14 +718,14 @@ that shows relative frequencies from our sample of 20 $y_T$'s.
716718
717719Here is another figure, this time with 100 observations
718720
719- ``` {code-cell} python3
721+ ``` {code-cell} ipython3
720722t = 100
721723cross_section_plot(A_2, C_2, G_2, T=t)
722724```
723725
724726Let's now try with 500,000 observations, showing only the histogram (without rotation)
725727
726- ``` {code-cell} python3
728+ ``` {code-cell} ipython3
727729T = 100
728730ymin=-0.8
729731ymax=1.25
@@ -733,7 +735,7 @@ ar = LinearStateSpace(A_2, C_2, G_2, mu_0=np.ones(4))
733735fig, ax = plt.subplots()
734736x, y = ar.simulate(sample_size)
735737mu_x, mu_y, Sigma_x, Sigma_y, Sigma_yx = ar.stationary_distributions()
736- f_y = norm(loc=float(mu_y) , scale=float(np.sqrt(Sigma_y)))
738+ f_y = norm(loc=float(mu_y.item()) , scale=float(np.sqrt(Sigma_y.item() )))
737739y = y.flatten()
738740ygrid = np.linspace(ymin, ymax, 150)
739741
@@ -776,7 +778,8 @@ The parameters are the same as for the preceding figures,
776778and the sample size is relatively small ($I=20$).
777779
778780(lss_em_fig)=
779- ``` {code-cell} python3
781+
782+ ``` {code-cell} ipython3
780783I = 20
781784T = 50
782785ymin = -0.5
@@ -904,7 +907,7 @@ Let's look at some more time series from the same model that we analyzed above.
904907This picture shows cross-sectional distributions for $y$ at times
905908$T, T', T''$
906909
907- ``` {code-cell} python3
910+ ``` {code-cell} ipython3
908911def cross_plot(A,
909912 C,
910913 G,
@@ -944,7 +947,7 @@ def cross_plot(A,
944947 plt.show()
945948```
946949
947- ``` {code-cell} python3
950+ ``` {code-cell} ipython3
948951cross_plot(A_2, C_2, G_2)
949952```
950953
@@ -988,7 +991,8 @@ where $\mu_{\infty}$ and $\Sigma_{\infty}$ are fixed points of {eq}`lss_mut_line
988991Let's see what happens to the preceding figure if we start $x_0$ at the stationary distribution.
989992
990993(lss_s_fig)=
991- ``` {code-cell} python3
994+
995+ ``` {code-cell} ipython3
992996cross_plot(A_2, C_2, G_2, steady_state='True')
993997```
994998
0 commit comments