Skip to content

[aiyagari] MAINT: transfer np.sum(a * b) to a @ b #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions lectures/aiyagari.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.16.7
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
---
Expand All @@ -26,10 +28,9 @@ kernelspec:

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

```{code-cell} ipython
---
tags: [hide-output]
---
```{code-cell} ipython3
:tags: [hide-output]

!pip install quantecon
```

Expand All @@ -54,7 +55,7 @@ The Aiyagari model has been used to investigate many topics, including

Let's start with some imports:

```{code-cell} ipython
```{code-cell} ipython3
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
import numpy as np
Expand Down Expand Up @@ -208,7 +209,7 @@ when the parameters change.

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

```{code-cell} python3
```{code-cell} ipython3
class Household:
"""
This class takes the parameters that define a household asset accumulation
Expand Down Expand Up @@ -318,7 +319,7 @@ def asset_marginal(s_probs, a_size, z_size):

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

```{code-cell} python3
```{code-cell} ipython3
# Example prices
r = 0.03
w = 0.956
Expand Down Expand Up @@ -366,7 +367,7 @@ The following code draws aggregate supply and demand curves.

The intersection gives equilibrium interest rates and capital.

```{code-cell} python3
```{code-cell} ipython3
A = 1.0
N = 1.0
α = 0.33
Expand Down Expand Up @@ -410,7 +411,7 @@ def prices_to_capital_stock(am, r):
# Extract the marginal distribution for assets
asset_probs = asset_marginal(stationary_probs, am.a_size, am.z_size)
# Return K
return np.sum(asset_probs * am.a_vals)
return asset_probs @ am.a_vals


# Create an instance of Household
Expand Down
Loading