Skip to content

Commit 2350f79

Browse files
authored
Merge branch 'main' into update-tex-macros
2 parents cc9b96f + 8b26847 commit 2350f79

36 files changed

+435
-317
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,22 @@ jobs:
2121
- name: Display Pip Versions
2222
shell: bash -l {0}
2323
run: pip list
24+
- name: Download "build" folder (cache)
25+
uses: dawidd6/action-download-artifact@v2
26+
with:
27+
workflow: publish.yml
28+
branch: main
29+
name: build-cache
30+
path: _build
2431
- name: Build HTML
2532
shell: bash -l {0}
2633
run: |
2734
jb build lectures --path-output ./
35+
- name: Save Build as Artifact
36+
uses: actions/upload-artifact@v1
37+
with:
38+
name: _build
39+
path: _build
2840
- name: Preview Deploy to Netlify
2941
uses: nwtgck/[email protected]
3042
with:

.github/workflows/publish.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ jobs:
4343
github_token: ${{ secrets.GITHUB_TOKEN }}
4444
publish_dir: _build/html/
4545
# cname: python.quantecon.org
46+
- name: Upload "_build" folder (cache)
47+
uses: actions/upload-artifact@v2
48+
with:
49+
name: build-cache
50+
path: _build
4651
# - name: Prepare lecture-python.notebooks sync
4752
# shell: bash -l {0}
4853
# run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_build/
2+
lectures/_build/

environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ channels:
33
- default
44
dependencies:
55
- python=3.8
6-
- anaconda=2020.07
6+
- anaconda=2020.11
77
- pip
88
- pip:
9-
- git+https://github.com/executablebooks/jupyter-book
9+
- jupyter-book
1010
- sphinxext-rediraffe
1111
- sphinx-multitoc-numbering
1212
- quantecon-book-theme

lectures/_config.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,41 @@ description: This website presents a set of lectures on quantitative economic mo
55

66
execute:
77
execute_notebooks: "cache"
8-
timeout: 60
8+
timeout: 600
9+
10+
bibtex_bibfiles:
11+
- _static/quant-econ.bib
12+
13+
bibtex_bibfiles:
14+
- _static/quant-econ.bib
915

1016
html:
1117
baseurl: https://python.quantecon.org/
1218

1319
sphinx:
1420
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter]
1521
config:
22+
nb_render_priority:
23+
html:
24+
- "application/vnd.jupyter.widget-view+json"
25+
- "application/javascript"
26+
- "text/html"
27+
- "text/latex"
28+
- "image/svg+xml"
29+
- "image/png"
30+
- "image/jpeg"
31+
- "text/markdown"
32+
- "text/plain"
33+
jupyter:
34+
- "application/vnd.jupyter.widget-view+json"
35+
- "application/javascript"
36+
- "text/html"
37+
- "text/latex"
38+
- "image/svg+xml"
39+
- "image/png"
40+
- "image/jpeg"
41+
- "text/markdown"
42+
- "text/plain"
1643
html_favicon: _static/lectures-favicon.ico
1744
html_theme: quantecon_book_theme
1845
html_static_path: ['_static']
@@ -31,6 +58,7 @@ sphinx:
3158
Macros:
3259
"argmax" : "arg\\,max"
3360
"argmin" : "arg\\,min"
61+
mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
3462
rediraffe_redirects:
3563
index_toc.md: intro.md
3664
tojupyter_static_file_path: ["source/_static", "_static"]

lectures/cake_eating_numerical.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ where $u$ is the CRRA utility function.
7272
The analytical solutions for the value function and optimal policy were found
7373
to be as follows.
7474

75-
```{literalinclude} _static/lecture_specific/cake_eating_numerical/analytical.py
75+
```{code-cell} python3
76+
:load: _static/lecture_specific/cake_eating_numerical/analytical.py
7677
```
7778

7879
Our first aim is to obtain these analytical solutions numerically.

lectures/cass_koopmans_2.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ all other dates $t=1, 2, \ldots, T$.
195195
There are sequences of prices
196196
$\{w_t,\eta_t\}_{t=0}^T= \{\vec{w}, \vec{\eta} \}$
197197
where $w_t$ is a wage or rental rate for labor at time $t$ and
198-
$eta_t$ is a rental rate for capital at time $t$.
198+
$\eta_t$ is a rental rate for capital at time $t$.
199199

200200
In addition there is are intertemporal prices that work as follows.
201201

@@ -397,7 +397,7 @@ verify** approach.
397397
In this lecture {doc}`Cass-Koopmans Planning Model <cass_koopmans_1>`, we computed an allocation $\{\vec{C}, \vec{K}, \vec{N}\}$
398398
that solves the planning problem.
399399

400-
(This allocation will constitute the **Big** $K$ to be in the present instance of the *Big** $K$ **, little** $k$ trick
400+
(This allocation will constitute the **Big** $K$ to be in the present instance of the **Big** $K$ **, little** $k$ trick
401401
that we'll apply to a competitive equilibrium in the spirit of [this lecture](https://lectures.quantecon.org/py/rational_expectations.html#)
402402
and [this lecture](https://lectures.quantecon.org/py/dyn_stack.html#).)
403403

@@ -835,9 +835,9 @@ for T in T_arr:
835835
for i, ax in enumerate(axs.flatten()):
836836
ax.plot(paths[i])
837837
ax.set(title=titles[i], ylabel=ylabels[i], xlabel='t')
838-
if titles[i] is 'Capital':
838+
if titles[i] == 'Capital':
839839
ax.axhline(k_ss, lw=1, ls='--', c='k')
840-
if titles[i] is 'Consumption':
840+
if titles[i] == 'Consumption':
841841
ax.axhline(c_ss, lw=1, ls='--', c='k')
842842
843843
plt.tight_layout()
@@ -871,9 +871,9 @@ for γ in γ_arr:
871871
for i, ax in enumerate(axs.flatten()):
872872
ax.plot(paths[i], label=f'$\gamma = {γ}$')
873873
ax.set(title=titles[i], ylabel=ylabels[i], xlabel='t')
874-
if titles[i] is 'Capital':
874+
if titles[i] == 'Capital':
875875
ax.axhline(k_ss, lw=1, ls='--', c='k')
876-
if titles[i] is 'Consumption':
876+
if titles[i] == 'Consumption':
877877
ax.axhline(c_ss, lw=1, ls='--', c='k')
878878
879879
axs[0, 0].legend()
@@ -893,7 +893,7 @@ Vice-versa for lower $\gamma$.
893893

894894
We return to Hicks-Arrow prices and calculate how they are related to **yields** on loans of alternative maturities.
895895

896-
This will let us plot a **yield curve** that graphs yields on bonds of maturities $j=1, 2, \ldots$ against :math:j=1,2, ldots`.
896+
This will let us plot a **yield curve** that graphs yields on bonds of maturities $j=1, 2, \ldots$ against $j=1,2, \ldots$.
897897

898898
The formulas we want are:
899899

lectures/coleman_policy_iter.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ As in our {doc}`previous study <optgrowth_fast>`, we continue to assume that
267267

268268
This will allow us to compare our results to the analytical solutions
269269

270-
```{literalinclude} _static/lecture_specific/optgrowth/cd_analytical.py
270+
```{code-cell} python3
271+
:load: _static/lecture_specific/optgrowth/cd_analytical.py
271272
```
272273

273274
As discussed above, our plan is to solve the model using time iteration, which
@@ -278,7 +279,8 @@ For this we need access to the functions $u'$ and $f, f'$.
278279
These are available in a class called `OptimalGrowthModel` that we
279280
constructed in an {doc}`earlier lecture <optgrowth_fast>`.
280281

281-
```{literalinclude} _static/lecture_specific/optgrowth_fast/ogm.py
282+
```{code-cell} python3
283+
:load: _static/lecture_specific/optgrowth_fast/ogm.py
282284
```
283285

284286
Now we implement a method called `euler_diff`, which returns
@@ -374,7 +376,8 @@ Here is a function called `solve_model_time_iter` that takes an instance of
374376
`OptimalGrowthModel` and returns an approximation to the optimal policy,
375377
using time iteration.
376378

377-
```{literalinclude} _static/lecture_specific/coleman_policy_iter/solve_time_iter.py
379+
```{code-cell} python3
380+
:load: _static/lecture_specific/coleman_policy_iter/solve_time_iter.py
378381
```
379382

380383
Let's call it:
@@ -439,7 +442,8 @@ Compute and plot the optimal policy.
439442

440443
We use the class `OptimalGrowthModel_CRRA` from our {doc}`VFI lecture <optgrowth_fast>`.
441444

442-
```{literalinclude} _static/lecture_specific/optgrowth_fast/ogm_crra.py
445+
```{code-cell} python3
446+
:load: _static/lecture_specific/optgrowth_fast/ogm_crra.py
443447
```
444448

445449
Let's create an instance:

lectures/complex_and_trig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ eq1 = Eq(x1/x0 - r * cos(ω+θ) / cos(ω), 0)
310310
print(f'ω = {ω:1.3f}')
311311
312312
# Solve for p
313-
eq2 = Eq(x0 - 2 * p * cos(ω))
313+
eq2 = Eq(x0 - 2 * p * cos(ω), 0)
314314
p = nsolve(eq2, p, 0)
315315
p = np.float(p)
316316
print(f'p = {p:1.3f}')

lectures/egm_policy_iter.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,14 @@ where
160160

161161
This will allow us to make comparisons with the analytical solutions
162162

163-
```{literalinclude} _static/lecture_specific/optgrowth/cd_analytical.py
163+
```{code-cell} python3
164+
:load: _static/lecture_specific/optgrowth/cd_analytical.py
164165
```
165166

166167
We reuse the `OptimalGrowthModel` class
167168

168-
```{literalinclude} _static/lecture_specific/optgrowth_fast/ogm.py
169+
```{code-cell} python3
170+
:load: _static/lecture_specific/optgrowth_fast/ogm.py
169171
```
170172

171173
### The Operator
@@ -216,7 +218,8 @@ grid = og.grid
216218

217219
Here's our solver routine:
218220

219-
```{literalinclude} _static/lecture_specific/coleman_policy_iter/solve_time_iter.py
221+
```{code-cell} python3
222+
:load: _static/lecture_specific/coleman_policy_iter/solve_time_iter.py
220223
```
221224

222225
Let's call it:

lectures/exchangeable.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ that are
5353
Understanding the distinction between these concepts is essential for appreciating how Bayesian updating
5454
works in our example.
5555

56-
You can read about exchangeability [here](https://en.wikipedia.org/wiki/Exchangeable_random_variables)
56+
You can read about exchangeability [here](https://en.wikipedia.org/wiki/Exchangeable_random_variables).
5757

5858
Below, we'll often use
5959

@@ -116,10 +116,10 @@ $$
116116
Using the laws of probability, we can always factor such a joint density into a product of conditional densities:
117117

118118
$$
119-
\begin{align}
120-
p(W_T, W_{T-1}, \ldots, W_1, W_0) = & p(W_T | W_{t-1}, \ldots, W_0) p(W_{T-1} | W_{T-2}, \ldots, W_0) \cdots \cr
121-
& p(W_1 | W_0) p(W_0)
122-
\end{align}
119+
\begin{aligned}
120+
p(W_T, W_{T-1}, \ldots, W_1, W_0) = & p(W_T | W_{T-1}, \ldots, W_0) p(W_{T-1} | W_{T-2}, \ldots, W_0) \cdots \cr
121+
& \quad \quad \cdots p(W_1 | W_0) p(W_0)
122+
\end{aligned}
123123
$$
124124

125125
In general,
@@ -140,16 +140,14 @@ and partial history $W_{t-1}, \ldots, W_0$ contains no information about the pro
140140

141141
So in the IID case, there is **nothing to learn** about the densities of future random variables from past data.
142142

143-
In the general case, there is something go learn from past data.
143+
In the general case, there is something to learn from past data.
144144

145-
We turn next to an instance of this general case in which there is something to learn from past data.
145+
We turn next to an instance of this general case.
146146

147147
Please keep your eye out for **what** there is to learn from past data.
148148

149149
## A Setting in Which Past Observations Are Informative
150150

151-
We now turn to a setting in which there **is** something to learn.
152-
153151
Let $\{W_t\}_{t=0}^\infty$ be a sequence of nonnegative
154152
scalar random variables with a joint probability distribution
155153
constructed as follows.
@@ -174,15 +172,15 @@ of them once and for all and then drew an IID sequence of draws from that distri
174172

175173
But our decision maker does not know which of the two distributions nature selected.
176174

177-
The decision maker summarizes his ignorance about this by picking a **subjective probability**
175+
The decision maker summarizes his ignorance with a **subjective probability**
178176
$\tilde \pi$ and reasons as if nature had selected $F$ with probability
179177
$\tilde \pi \in (0,1)$ and
180178
$G$ with probability $1 - \tilde \pi$.
181179

182180
Thus, we assume that the decision maker
183181

184182
- **knows** both $F$ and $G$
185-
- **doesnt't know** which of these two distributions that nature has drawn
183+
- **doesn't know** which of these two distributions that nature has drawn
186184
- summarizing his ignorance by acting as if or **thinking** that nature chose distribution $F$ with probability $\tilde \pi \in (0,1)$ and distribution
187185
$G$ with probability $1 - \tilde \pi$
188186
- at date $t \geq 0$ has observed the partial history $w_t, w_{t-1}, \ldots, w_0$ of draws from the appropriate joint
@@ -276,7 +274,7 @@ as a **prior probability** that nature selected probability distribution $F$.
276274
DeFinetti {cite}`definetti` established a related representation of an exchangeable process created by mixing
277275
sequences of IID Bernoulli random variables with parameters $\theta$ and mixing probability $\pi(\theta)$
278276
for a density $\pi(\theta)$ that a Bayesian statistician would interpret as a prior over the unknown
279-
Bernoulli paramter $\theta$.
277+
Bernoulli parameter $\theta$.
280278

281279
## Bayes' Law
282280

@@ -287,7 +285,7 @@ But how can we learn?
287285

288286
And about what?
289287

290-
The answer to the *about what* question is about $\tilde pi$.
288+
The answer to the *about what* question is about $\tilde \pi$.
291289

292290
The answer to the *how* question is to use Bayes' Law.
293291

@@ -302,7 +300,7 @@ $$
302300
\pi = \mathbb{P}\{q = f \}
303301
$$
304302

305-
where we regard $\pi$ as the decision maker's **subjective probability** (also called a **personal probability**.
303+
where we regard $\pi$ as the decision maker's **subjective probability** (also called a **personal probability**).
306304

307305
Suppose that at $t \geq 0$, the decision maker has observed a history
308306
$w^t \equiv [w_t, w_{t-1}, \ldots, w_0]$.
@@ -484,18 +482,18 @@ learning_example()
484482
```
485483

486484
Please look at the three graphs above created for an instance in which $f$ is a uniform distribution on $[0,1]$
487-
(i.e., a Beta distribution with parameters $F_a=1, F_b=1$, while $g$ is a Beta distribution with the default parameter values $G_a=3, G_b=1.2$.
485+
(i.e., a Beta distribution with parameters $F_a=1, F_b=1$), while $g$ is a Beta distribution with the default parameter values $G_a=3, G_b=1.2$.
488486

489-
The graph in the left plots the likehood ratio $l(w)$ on the coordinate axis against $w$ on the coordinate axis.
487+
The graph on the left plots the likelihood ratio $l(w)$ on the coordinate axis against $w$ on the ordinate axis.
490488

491489
The middle graph plots both $f(w)$ and $g(w)$ against $w$, with the horizontal dotted lines showing values
492490
of $w$ at which the likelihood ratio equals $1$.
493491

494-
The graph on the right side plots arrows to the right that show when Bayes' Law makes $\pi$ increase and arrows
492+
The graph on the right plots arrows to the right that show when Bayes' Law makes $\pi$ increase and arrows
495493
to the left that show when Bayes' Law make $\pi$ decrease.
496494

497495
Notice how the length of the arrows, which show the magnitude of the force from Bayes' Law impelling $\pi$ to change,
498-
depend on both the prior probability $\pi$ on the ordinate axis and the evidence in the form of the current draw of
496+
depends on both the prior probability $\pi$ on the ordinate axis and the evidence in the form of the current draw of
499497
$w$ on the coordinate axis.
500498

501499
The fractions in the colored areas of the middle graphs are probabilities under $F$ and $G$, respectively,
@@ -532,7 +530,7 @@ assumptions about nature's choice of distribution:
532530
- that nature permanently draws from $G$
533531

534532
Outcomes depend on a peculiar property of likelihood ratio processes that are discussed in
535-
[this lecture](https://python-advanced.quantecon.org/additive_functionals.html)
533+
[this lecture](https://python-advanced.quantecon.org/additive_functionals.html).
536534

537535
To do this, we create some Python code.
538536

0 commit comments

Comments
 (0)