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

---

@@ -25,10 +27,9 @@ kernelspec:

25272628

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

272928-

```{code-cell} ipython

29-

---

30-

tags: [hide-output]

31-

---

30+

```{code-cell} ipython3

31+

:tags: [hide-output]

32+3233

!pip install --upgrade quantecon

3334

```

3435

@@ -73,7 +74,7 @@ We cover only the key features of the problem in this lecture, leaving you to re

73747475

We'll need the following imports:

757676-

```{code-cell} ipython

77+

```{code-cell} ipython3

7778

import sys

7879

import numpy as np

7980

import matplotlib.pyplot as plt

@@ -583,7 +584,7 @@ The following code provides functions for

583584584585

Description and clarifications are given below

585586586-

```{code-cell} python3

587+

```{code-cell} ipython3

587588

# Set up a namedtuple to store data on the model economy

588589

Economy = namedtuple('economy',

589590

('β', # Discount factor

@@ -694,7 +695,7 @@ def compute_paths(T, econ):

694695

a0 = 0.5 * (F @ (x_vals.T @ Sm.T)**2)[0]

695696

H = ((Sb - Sd + Sg) @ x_vals) * ((Sg - Ss) @ x_vals)

696697

b0 = 0.5 * (F @ H.T)[0]

697-

a0, b0 = float(a0), float(b0)

698+

a0, b0 = float(a0[0]), float(b0[0])

698699

else:

699700

H = Sm.T @ Sm

700701

a0 = 0.5 * var_quadratic_sum(A, C, H, β, x0)

@@ -889,7 +890,7 @@ with $\rho = 0.7$, $\mu_g = 0.35$ and $C_g = \mu_g \sqrt{1 - \rho^2} / 10$.

889890890891

Here's the code

891892892-

```{code-cell} python3

893+

```{code-cell} ipython3

893894

# == Parameters == #

894895

β = 1 / 1.05

895896

ρ, mg = .7, .35

@@ -915,7 +916,7 @@ The legends on the figures indicate the variables being tracked.

915916

Most obvious from the figure is tax smoothing in the sense that tax revenue is

916917

much less variable than government expenditure.

917918918-

```{code-cell} python3

919+

```{code-cell} ipython3

919920

gen_fig_2(path)

920921

```

921922

@@ -931,7 +932,7 @@ See the original [manuscript](https://lectures.quantecon.org/_downloads/firenze.

931932932933

Our second example adopts a discrete Markov specification for the exogenous process

933934934-

```{code-cell} python3

935+

```{code-cell} ipython3

935936

# == Parameters == #

936937

β = 1 / 1.05

937938

P = np.array([[0.8, 0.2, 0.0],

@@ -961,7 +962,7 @@ gen_fig_1(path)

961962962963

The call `gen_fig_2(path)` generates

963964964-

```{code-cell} python3

965+

```{code-cell} ipython3

965966

gen_fig_2(path)

966967

```

967968

@@ -997,7 +998,7 @@ Produce the corresponding figures.

997998

:class: dropdown

998999

```

99910001000-

```{code-cell} python3

1001+

```{code-cell} ipython3

10011002

# == Parameters == #

10021003

β = 1 / 1.05

10031004

ρ, mg = .95, .35

@@ -1023,10 +1024,11 @@ path = compute_paths(T, economy)

10231024

gen_fig_1(path)

10241025

```

102510261026-

```{code-cell} python3

1027+

```{code-cell} ipython3

10271028

gen_fig_2(path)

10281029

```

1029103010301031

```{solution-end}

10311032

```

103210331034+

Read the original on github.com ↗