GitHub

@@ -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

68

kernelspec:

7-

display_name: Python 3

9+

display_name: Python 3 (ipykernel)

810

language: python

911

name: python3

1012

---

@@ -26,10 +28,9 @@ kernelspec:

26282729

In 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

54555556

Let's start with some imports:

565757-

```{code-cell} ipython

58+

```{code-cell} ipython3

5859

import matplotlib.pyplot as plt

5960

plt.rcParams["figure.figsize"] = (11, 5) #set default figure size

6061

import numpy as np

@@ -208,7 +209,7 @@ when the parameters change.

208209209210

The class also includes a default set of parameters that we'll adopt unless otherwise specified.

210211211-

```{code-cell} python3

212+

```{code-cell} ipython3

212213

class 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):

318319319320

As 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

323324

r = 0.03

324325

w = 0.956

@@ -366,7 +367,7 @@ The following code draws aggregate supply and demand curves.

366367367368

The intersection gives equilibrium interest rates and capital.

368369369-

```{code-cell} python3

370+

```{code-cell} ipython3

370371

A = 1.0

371372

N = 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

Read the original on github.com ↗