Skip to content

Commit 2dac229

Browse files
authored
MAINT: update the software stack (#185)
* update the software stack * upgrade to sphinx-tojupyter==0.2.0 * update mathjax settings for sphinx4 * re-enable svg version of mathjax * upgrade to jupyter-book==0.12.1 * update to 2021.11 anaconda * adjust mathjax config * configure myst-parser with specified extensions * add in sans fonts * try font-manager * Try and regenerate font-manager * install basic fonts * just use standard fonts * adjustments to prob_meaning lecture * adjust to letters
1 parent 3a4b426 commit 2dac229

File tree

5 files changed

+44
-42
lines changed

5 files changed

+44
-42
lines changed

.DS_Store

-8 KB
Binary file not shown.

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ jobs:
2727
latexmk \
2828
xindy \
2929
dvipng \
30-
cm-super
30+
cm-super \
31+
msttcorefonts
3132
- name: Display Conda Environment Versions
3233
shell: bash -l {0}
3334
run: conda list

environment.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@ channels:
33
- default
44
dependencies:
55
- python=3.8
6-
- anaconda=2020.11
6+
- anaconda=2021.11
77
- pip
88
- pip:
9-
- jupyter-book==0.11.2
9+
- jupyter-book==0.12.1
1010
- quantecon-book-theme==0.3.0
11-
- sphinx-tojupyter==0.1.2
11+
- sphinx-tojupyter==0.2.0
1212
- sphinxext-rediraffe==0.2.7
13-
- sphinx-exercise==0.1.1
14-
- jupytext==1.11.2
13+
- sphinx-exercise==0.2.1
1514
- ghp-import==1.1.0
16-
- jupinx==0.2.3
1715
- sphinxcontrib-youtube
18-
# Temporary Fixes
19-
- tornado>=6.1
2016

lectures/_config.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ author: Thomas J. Sargent & John Stachurski
33
logo: _static/qe-logo-large.png
44
description: This website presents a set of lectures on quantitative economic modeling, designed and written by Thomas J. Sargent and John Stachurski.
55

6+
parse:
7+
myst_enable_extensions:
8+
- amsmath
9+
- colon_fence
10+
- deflist
11+
- dollarmath
12+
- html_admonition
13+
- html_image
14+
- linkify
15+
- replacements
16+
- smartquotes
17+
- substitution
18+
619
only_build_toc_files: true
720
execute:
821
execute_notebooks: "cache"
@@ -56,9 +69,9 @@ sphinx:
5669
description: This website presents a set of lectures on quantitative economic modeling, designed and written by Thomas J. Sargent and John Stachurski.
5770
keywords: Python, QuantEcon, Quantitative Economics, Economics, Sloan, Alfred P. Sloan Foundation, Tom J. Sargent, John Stachurski
5871
google_analytics_id: UA-54984338-10
59-
mathjax_config:
60-
TeX:
61-
Macros:
72+
mathjax3_config:
73+
tex:
74+
macros:
6275
"argmax" : "arg\\,max"
6376
"argmin" : "arg\\,min"
6477
mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-svg.js

lectures/prob_meaning.md

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,7 @@ import prettytable as pt
6565
import matplotlib.pyplot as plt
6666
from scipy.stats import binom
6767
import scipy.stats as st
68-
from matplotlib import rcParams
69-
from IPython.display import set_matplotlib_formats
70-
set_matplotlib_formats('retina')
7168
%matplotlib inline
72-
73-
config = {
74-
"font.family":'serif',
75-
"mathtext.fontset": 'stix',
76-
"font.serif": ['SimSun'],
77-
}
78-
rcParams.update(config)
7969
```
8070

8171
Empowered with these Python tools, we'll now explore the two meanings described above.
@@ -133,12 +123,12 @@ As usual, a law of large numbers justifies this answer.
133123

134124
**Exercise 1:**
135125

136-
* (a) Please write a Python class to compute $f_k^I$
126+
1. Please write a Python class to compute $f_k^I$
137127

138-
* (b) Please use your code to compute $f_k^I, k = 0, \ldots , n$ and compare them to
128+
2. Please use your code to compute $f_k^I, k = 0, \ldots , n$ and compare them to
139129
$\textrm{Prob}(X = k | \theta)$ for various values of $\theta, n$ and $I$
140130

141-
* (c) With the Law of Large numbers in mind, use your code to say something
131+
3. With the Law of Large numbers in mind, use your code to say something
142132

143133
+++
144134

@@ -360,25 +350,27 @@ a beta distribution with parameters $\alpha, \beta$.
360350

361351
**Exercise 2:**
362352

363-
* (a) Please write down the **likelihood function** for a sample of length $n$ from a binomial distribution with parameter $\theta$.
353+
**a)** Please write down the **likelihood function** for a sample of length $n$ from a binomial distribution with parameter $\theta$.
354+
355+
**b)** Please write down the **posterior** distribution for $\theta$ after observing one flip of the coin.
364356

365-
* (b) Please write down the **posterior** distribution for $\theta$ after observing one flip of the coin.
357+
**c)** Please pretend that the true value of $\theta = .4$ and that someone who doesn't know this has a beta prior distribution with parameters with $\beta = \alpha = .5$.
366358

367-
* (c) Please pretend that the true value of $\theta = .4$ and that someone who doesn't know this has a beta prior distribution with parameters with $\beta = \alpha = .5$.
359+
**d)** Please write a Python class to simulate this person's personal posterior distribution for $\theta$ for a _single_ sequence of $n$ draws.
368360

369-
* (d) Please write a Python class to simulate this person's personal posterior distribution for $\theta$ for a _single_ sequence of $n$ draws.
361+
**e)** Please plot the posterior distribution for $\theta$ as a function of $\theta$ as $n$ grows from $1, 2, \ldots$.
370362

371-
* (e) Please plot the posterior distribution for $\theta$ as a function of $\theta$ as $n$ grows from $1, 2, \ldots$.
363+
**f)** For various $n$'s, please describe and compute a Bayesian coverage interval for the interval $[.45, .55]$.
372364

373-
* (f) For various $n$'s, please describe and compute a Bayesian coverage interval for the interval $[.45, .55]$.
365+
**g)** Please tell what question a Bayesian coverage interval answers.
374366

375-
* (g) Please tell what question a Bayesian coverage interval answers.
367+
**h)** Please compute the Posterior probabililty that $\theta \in [.45, .55]$ for various values of sample size $n$.
376368

377-
* (h) Please use your Python class to study what happens to the posterior distribution as $n \rightarrow + \infty$, again assuming that the true value of $\theta = .4$, though it is unknown to the person doing the updating via Bayes' Law.
369+
**i)** Please use your Python class to study what happens to the posterior distribution as $n \rightarrow + \infty$, again assuming that the true value of $\theta = .4$, though it is unknown to the person doing the updating via Bayes' Law.
378370

379371
**Answer:**
380372

381-
* (a) Please write down the **likelihood function** and the **posterior** distribution for $\theta$ after observing one flip of our coin.
373+
**a)** Please write down the **likelihood function** and the **posterior** distribution for $\theta$ after observing one flip of our coin.
382374

383375
Suppose the outcome is __Y__.
384376

@@ -389,7 +381,7 @@ L(Y|\theta)= \textrm{Prob}(X = Y | \theta) =
389381
\theta^Y (1-\theta)^{1-Y}
390382
$$
391383

392-
* (b) Please write the **posterior** distribution for $\theta$ after observing one flip of our coin.
384+
**b)** Please write the **posterior** distribution for $\theta$ after observing one flip of our coin.
393385

394386
The prior distribution is
395387

@@ -412,9 +404,9 @@ $$
412404
\textrm{Prob}(\theta | Y) \sim \textrm{Beta}(\alpha + Y, \beta + (1-Y))
413405
$$
414406

415-
* (c) Please pretend that the true value of $\theta = .4$ and that someone who doesn't know this has a beta prior with $\beta = \alpha = .5$.
407+
**c)** Please pretend that the true value of $\theta = .4$ and that someone who doesn't know this has a beta prior with $\beta = \alpha = .5$.
416408

417-
* (d) Please write a Python class to simulate this person's personal posterior distribution for $\theta$ for a _single_ sequence of $n$ draws.
409+
**d)** Please write a Python class to simulate this person's personal posterior distribution for $\theta$ for a _single_ sequence of $n$ draws.
418410

419411
```{code-cell} ipython3
420412
class Bayesian:
@@ -478,7 +470,7 @@ class Bayesian:
478470
self.posterior_list.append(self.form_single_posterior(num))
479471
```
480472

481-
* (e) Please plot the posterior distribution for $\theta$ as a function of $\theta$ as $n$ grows from $1, 2, \ldots$.
473+
**e)** Please plot the posterior distribution for $\theta$ as a function of $\theta$ as $n$ grows from $1, 2, \ldots$.
482474

483475
```{code-cell} ipython3
484476
Bay_stat = Bayesian()
@@ -505,7 +497,7 @@ ax.legend(fontsize=11)
505497
plt.show()
506498
```
507499

508-
* (f) For various $n$'s, please describe and compute $.05$ and $.95$ quantiles for posterior probabilities.
500+
**f)** For various $n$'s, please describe and compute $.05$ and $.95$ quantiles for posterior probabilities.
509501

510502
```{code-cell} ipython3
511503
upper_bound = [ii.ppf(0.05) for ii in Bay_stat.posterior_list[:14]]
@@ -521,7 +513,7 @@ interval_df
521513

522514
As n increases, we can see that Bayesian coverage intervals narrow and move toward $0.4$.
523515

524-
* (g) Please tell what question a Bayesian coverage interval answers.
516+
**g)** Please tell what question a Bayesian coverage interval answers.
525517

526518
The Bayesian coverage interval tells the range of $\theta$ that corresponds to the [$p_1$, $p_2$] quantiles of the cumulative probability distribution (CDF) of the posterior distribution.
527519

@@ -533,7 +525,7 @@ $$
533525
F(a)=p_1,F(b)=p_2
534526
$$
535527

536-
* (h) Please compute the Posterior probabililty that $\theta \in [.45, .55]$ for various values of sample size $n$.
528+
**h)** Please compute the Posterior probabililty that $\theta \in [.45, .55]$ for various values of sample size $n$.
537529

538530
```{code-cell} ipython3
539531
left_value, right_value = 0.45, 0.55
@@ -567,7 +559,7 @@ When the number of observations becomes large enough, our Bayesian becomes so co
567559

568560
That is why we see a nearly horizontal line when the number of observations exceeds 500.
569561

570-
* (i) Please use your Python class to study what happens to the posterior distribution as $n \rightarrow + \infty$, again assuming that the true value of $\theta = .4$, though it is unknown to the person doing the updating via Bayes' Law.
562+
**i)** Please use your Python class to study what happens to the posterior distribution as $n \rightarrow + \infty$, again assuming that the true value of $\theta = .4$, though it is unknown to the person doing the updating via Bayes' Law.
571563

572564
Using the Python class we made above, we can see the evolution of posterior distributions as n approaches infinity.
573565

0 commit comments

Comments
 (0)