Skip to content

Commit

Permalink
MAINT: Update anaconda, README, and bibtex style (#23)
Browse files Browse the repository at this point in the history
* update ga workflow version

* adjust formatting in bayes_nonconj

* upgrade to anaconda=2024.02

* default README format

* enable author-year bibtex style

* tmp: disable build cache
  • Loading branch information
mmcky authored Apr 29, 2024
1 parent 0fdd2b8 commit 85fc064
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
needs: deploy-runner
runs-on: [self-hosted, cml-gpu]
container:
image: docker://mmcky/quantecon-lecture-python:cuda-12.3.1-anaconda-2023-09-py311
image: docker://mmcky/quantecon-lecture-python:cuda-12.3.1-anaconda-2024-02-py311
options: --gpus all
steps:
- uses: actions/checkout@v4
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
needs: deploy-runner
runs-on: [self-hosted, cml-gpu]
container:
image: docker://mmcky/quantecon-lecture-python:cuda-12.3.1-anaconda-2023-09-py311
image: docker://mmcky/quantecon-lecture-python:cuda-12.3.1-anaconda-2024-02-py311
options: --gpus all
steps:
- uses: actions/checkout@v4
Expand All @@ -40,13 +40,13 @@ jobs:
- name: Display Pip Versions
shell: bash -l {0}
run: pip list
- name: Download "build" folder (cache)
uses: dawidd6/action-download-artifact@v2
with:
workflow: cache.yml
branch: main
name: build-cache
path: _build
# - name: Download "build" folder (cache)
# uses: dawidd6/action-download-artifact@v2
# with:
# workflow: cache.yml
# branch: main
# name: build-cache
# path: _build
# Build Assets (Download Notebooks and PDF via LaTeX)
- name: Build Download Notebooks (sphinx-tojupyter)
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Anaconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
auto-activate-base: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
needs: deploy-runner
runs-on: [self-hosted, cml-gpu]
container:
image: docker://mmcky/quantecon-lecture-python:cuda-12.3.1-anaconda-2023-09-py311
image: docker://mmcky/quantecon-lecture-python:cuda-12.3.1-anaconda-2024-02-py311
options: --gpus all
steps:
- name: Checkout
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# lecture-stats
# Statistics for Computational Economics

Statistics for Computational Economics
This website presents a set of lectures on statistics for computational economics.

## Jupyter notebooks

Jupyter notebook versions of each lecture are available for download
via the website.

## Contributions

To comment on the lectures please add to or open an issue in the issue tracker (see above).

We welcome pull requests!

Please read the [QuantEcon style guide](https://manual.quantecon.org/intro.html) first, so that you can match our style.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- default
dependencies:
- python=3.11
- anaconda=2023.09
- anaconda=2024.02
- pip
- pip:
- jupyter-book==0.15.1
Expand Down
1 change: 1 addition & 0 deletions lectures/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ latex:
sphinx:
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter, sphinxcontrib.youtube, sphinx.ext.todo, sphinx_exercise, sphinx_togglebutton, sphinx.ext.intersphinx, sphinx_reredirects]
config:
bibtex_reference_style: author_year
nb_mime_priority_overrides: [
# HTML
['html', 'application/vnd.jupyter.widget-view+json', 10],
Expand Down
15 changes: 7 additions & 8 deletions lectures/bayes_nonconj.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Having a likelihood and prior that are conjugate can simplify calculation of a

But in many situations the likelihood and prior need not form a conjugate pair.

- after all, a person's prior is his or her own business and would take a form conjugate to a likelihood only by remote coincidence
- after all, a person's prior is his or her own business and would take a form conjugate to a likelihood only by remote coincidence

In these situations, computing a posterior can become very challenging.

Expand Down Expand Up @@ -78,7 +78,7 @@ We use `numpyro` with assistance from `jax` to approximate a posterior distrib

We use several alternative prior distributions.

We compare computed posteriors with ones associated with a conjugate prior as described in {doc}`the quantecon lecture <prob_meaning>`.
We compare computed posteriors with ones associated with a conjugate prior as described in {doc}`the quantecon lecture <prob_meaning>`.


### Analytical Posterior
Expand Down Expand Up @@ -119,8 +119,6 @@ $$
=\frac{(1 -\theta)^{\beta+N-k-1} \theta^{\alpha+k-1}}{\int_0^1 (1 - \theta)^{\beta+N-k-1} \theta^{\alpha+k-1} d\theta} .
$$



Thus,

$$
Expand Down Expand Up @@ -191,7 +189,7 @@ By paying the cost of restricting the putative posterior to have a restricted fu
the problem of approximating a posteriors is transformed to a well-posed optimization problem that seeks parameters of the putative posterior that minimize
a Kullback-Leibler (KL) divergence between true posterior and the putatitive posterior distribution.

- minimizing the KL divergence is equivalent with maximizing a criterion called the **Evidence Lower Bound** (ELBO), as we shall verify soon.
- minimizing the KL divergence is equivalent with maximizing a criterion called the **Evidence Lower Bound** (ELBO), as we shall verify soon.

## Prior Distributions

Expand Down Expand Up @@ -277,14 +275,14 @@ $$
p\left(Y\right)=\int d\theta p\left(Y\mid\theta\right)p\left(Y\right).
$$ (eq:intchallenge)
The integral on the right side of {eq}`eq:intchallenge` is typically difficult to compute.
The integral on the right side of {eq}`eq:intchallenge` is typically difficult to compute.
Consider a **guide distribution** $q_{\phi}(\theta)$ parameterized by $\phi$ that we'll use to approximate the posterior.
We choose parameters $\phi$ of the guide distribution to minimize a Kullback-Leibler (KL) divergence between the approximate posterior $q_{\phi}(\theta)$ and the posterior:
$$
D_{KL}(q(\theta;\phi)\;\|\;p(\theta\mid Y)) \equiv -\int d\theta q(\theta;\phi)\log\frac{p(\theta\mid Y)}{q(\theta;\phi)}
D_{KL}(q(\theta;\phi)\;\|\;p(\theta\mid Y)) \equiv -\int d\theta q(\theta;\phi)\log\frac{p(\theta\mid Y)}{q(\theta;\phi)}
$$
Thus, we want a **variational distribution** $q$ that solves
Expand All @@ -296,7 +294,8 @@ $$
Note that
$$
\begin{aligned}D_{KL}(q(\theta;\phi)\;\|\;p(\theta\mid Y)) & =-\int d\theta q(\theta;\phi)\log\frac{P(\theta\mid Y)}{q(\theta;\phi)}\\
\begin{aligned}
D_{KL}(q(\theta;\phi)\;\|\;p(\theta\mid Y)) & =-\int d\theta q(\theta;\phi)\log\frac{P(\theta\mid Y)}{q(\theta;\phi)}\\
& =-\int d\theta q(\theta)\log\frac{\frac{p(\theta,Y)}{p(Y)}}{q(\theta)}\\
& =-\int d\theta q(\theta)\log\frac{p(\theta,Y)}{p(\theta)q(Y)}\\
& =-\int d\theta q(\theta)\left[\log\frac{p(\theta,Y)}{q(\theta)}-\log p(Y)\right]\\
Expand Down

0 comments on commit 85fc064

Please sign in to comment.