@@ -3,8 +3,10 @@ jupytext:
33text_representation:
44extension: .md
55format_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)
810language: python
911name: python3
1012---
@@ -26,10 +28,9 @@ kernelspec:
26282729In addition to what's in Anaconda, this lecture will need the following libraries:
283029-```{code-cell} ipython
30----
31-tags: [hide-output]
32----
31+```{code-cell} ipython3
32+:tags: [hide-output]
33+3334!pip install quantecon
3435```
3536@@ -54,7 +55,7 @@ The Aiyagari model has been used to investigate many topics, including
54555556Let's start with some imports:
565757-```{code-cell} ipython
58+```{code-cell} ipython3
5859import matplotlib.pyplot as plt
5960plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
6061import numpy as np
@@ -208,7 +209,7 @@ when the parameters change.
208209209210The class also includes a default set of parameters that we'll adopt unless otherwise specified.
210211211-```{code-cell} python3
212+```{code-cell} ipython3
212213class Household:
213214 """
214215 This class takes the parameters that define a household asset accumulation
@@ -318,7 +319,7 @@ def asset_marginal(s_probs, a_size, z_size):
318319319320As a first example of what we can do, let's compute and plot an optimal accumulation policy at fixed prices.
320321321-```{code-cell} python3
322+```{code-cell} ipython3
322323# Example prices
323324r = 0.03
324325w = 0.956
@@ -366,7 +367,7 @@ The following code draws aggregate supply and demand curves.
366367367368The intersection gives equilibrium interest rates and capital.
368369369-```{code-cell} python3
370+```{code-cell} ipython3
370371A = 1.0
371372N = 1.0
372373α = 0.33
@@ -410,7 +411,7 @@ def prices_to_capital_stock(am, r):
410411 # Extract the marginal distribution for assets
411412 asset_probs = asset_marginal(stationary_probs, am.a_size, am.z_size)
412413 # Return K
413- return np.sum(asset_probs * am.a_vals)
414+ return asset_probs @ am.a_vals
414415415416416417# Create an instance of Household