Skip to content

Commit 97cdd75

Browse files
authored
[aiyagari] MAINT: transfer np.sum(a * b) to a @ b (#467)
* MAINT: transfer np.sum(a * b) to a @ b * fix syntax error * remove test code
1 parent 7940e5f commit 97cdd75

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lectures/aiyagari.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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:
2628

2729
In addition to what's in Anaconda, this lecture will need the following libraries:
2830

29-
```{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
5455

5556
Let's start with some imports:
5657

57-
```{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.
208209

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

211-
```{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):
318319

319320
As a first example of what we can do, let's compute and plot an optimal accumulation policy at fixed prices.
320321

321-
```{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.
366367

367368
The intersection gives equilibrium interest rates and capital.
368369

369-
```{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
414415
415416
416417
# Create an instance of Household

0 commit comments

Comments
 (0)