diff --git a/.github/workflows/collab.yml b/.github/workflows/collab.yml index ec7301ae9..43cd2cb44 100644 --- a/.github/workflows/collab.yml +++ b/.github/workflows/collab.yml @@ -27,7 +27,7 @@ jobs: sphinx-togglebutton==0.4.5 \ arviz \ sphinx-proof==0.4.0 \ - sphinx-exercise==1.2.1 \ + sphinx-exercise==1.2.2 \ sphinx-reredirects==1.1.0 apt-get update apt-get install dvipng texlive texlive-latex-extra texlive-fonts-recommended cm-super diff --git a/environment.yml b/environment.yml index 599ece0d3..7314f0d16 100644 --- a/environment.yml +++ b/environment.yml @@ -10,7 +10,7 @@ dependencies: - quantecon-book-theme==0.22.1 - sphinx-tojupyter==0.6.0 - sphinxext-rediraffe==0.3.0 - - sphinx-exercise==1.2.1 + - sphinx-exercise==1.2.2 - sphinx-proof==0.4.0 - sphinxcontrib-youtube==1.5.0 - sphinx-togglebutton==0.4.5 diff --git a/lectures/exchange_rate_learning.md b/lectures/exchange_rate_learning.md index 50611388a..d569c1448 100644 --- a/lectures/exchange_rate_learning.md +++ b/lectures/exchange_rate_learning.md @@ -1318,6 +1318,12 @@ To compare like with like, run the Newton–Raphson learner at Arifovic's parame Here is part 1. ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: "Newton-Raphson learning at Arifovic's parameters" + name: fig-xr-ex4 +--- ea, sa, la = newton_learning(arifovic, [6.0, 4.0], [0.45, 0.55], T=3000) eb, sb, lb = newton_learning(arifovic, [6.0, 4.0], [0.45, 0.55], T=3000, κ=2.0) @@ -1460,6 +1466,12 @@ $\varepsilon_t \sim N(0, 1)$ and $\sigma = 1$, at Sargent's parameters. Here are parts 1 and 2. ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: "Limiting exchange rates from identical initial conditions" + name: fig-xr-ex5 +--- T, σ = 600, 1.0 e_det = newton_learning(kw, [3.0, 2.2], [0.30, 0.50], T=T)[0][-1] diff --git a/lectures/genetic_classifier.md b/lectures/genetic_classifier.md index 797f343e2..43f8596db 100644 --- a/lectures/genetic_classifier.md +++ b/lectures/genetic_classifier.md @@ -1647,6 +1647,12 @@ for b, P in paths.items(): The figure shows all forty paths. ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: "GA forecasters in Bray's market" + name: fig-gc-bray-ga +--- fig, axes = plt.subplots(1, 2, figsize=(10, 4), sharey=True) for ax, (b, P) in zip(axes, paths.items()): ax.plot(P.T, lw=1, alpha=0.6) diff --git a/lectures/information_transfer.md b/lectures/information_transfer.md index b97881efd..0a79f57f5 100644 --- a/lectures/information_transfer.md +++ b/lectures/information_transfer.md @@ -1149,6 +1149,12 @@ Under the coarse experiment the planner takes $a_2$ at $0.2$ and $a_1$ at $0.8$, Under the fine experiment the planner always takes $a_2$, so each player's expected utility is the height of that player's line for $a_2$ at the prior (open dot). ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Riley's example, with expected utilities read off at the prior + name: fig-it-riley +--- fig, axes = plt.subplots(1, 2, figsize=(10, 4)) for ax, mat, who in zip(axes, (U_ri, W_ri), ("planner", "agent")): for k in range(2): diff --git a/lectures/learning_approximation.md b/lectures/learning_approximation.md index 4442d9a42..9277da934 100644 --- a/lectures/learning_approximation.md +++ b/lectures/learning_approximation.md @@ -1211,6 +1211,12 @@ table.round(4) The rules themselves show the two failure modes. ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: "Kernel rules at three bandwidths" + name: fig-la-bandwidth +--- fig, ax = plt.subplots(figsize=(7, 4.2)) for h, colour in [(0.003, 'C0'), (0.03, 'C1'), (0.20, 'C2')]: ax.plot(G, kernel_smoother(T=T_short, h=h)[0], '-', lw=1, color=colour, label=f"$h = {h}$") @@ -1382,6 +1388,12 @@ eigenvalue of $DT(\theta^*)$. ``` ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: "Distance of online beliefs from the approximate equilibrium" + name: fig-la-rate +--- T_online = len(θ_path) ts = np.unique(np.logspace(2, np.log10(T_online - 1), 60).astype(int)) late = ts >= 10_000 diff --git a/lectures/lucas_prescott_search.md b/lectures/lucas_prescott_search.md index c1a5f1cfa..3b6f0cdaa 100644 --- a/lectures/lucas_prescott_search.md +++ b/lectures/lucas_prescott_search.md @@ -1413,6 +1413,12 @@ Eu2 = np.array([r['unemployment'] for r in res2]) The paper puts $\lambda$ on the vertical axis. ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Workforce demand and unemployment in the paper's two-state economy + name: fig-lps-two-state +--- fig, axes = plt.subplots(1, 2, figsize=(10, 4.2)) axes[0].plot(Ey2, grid2, lw=2) axes[0].set_xlabel('workforce demand per market') @@ -1688,6 +1694,12 @@ print(f"at U = 10 the largest gap on a grid of λ is {max(gaps_10):.4f}") Each of these inflows has two solutions, and each serves its own population; at $U = 10$ there are none. ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Undirected search, the populations served by the solutions at each inflow + name: fig-lps-undirected +--- Us = np.array(list(locus)) scale = 200/N_fine # back to the lecture's units fig, ax = plt.subplots(figsize=(7, 4)) @@ -1795,6 +1807,12 @@ for Δ in (-0.04, -0.02, -0.01, 0.01, 0.02, 0.04): The no-surprise line reproduces the equilibrium, as it should. ```{code-cell} ipython3 +--- +mystnb: + figure: + caption: An unanticipated shift in demand moves unemployment and wages in opposite directions + name: fig-lps-phillips +--- u_pts, w_pts = np.array(sorted(points)).T fig, ax = plt.subplots(figsize=(6.5, 4)) ax.plot(u_pts, w_pts, 'o-', lw=2)