From 85fc064cc13c3c538521d5a0f5c931daa8ba588e Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Tue, 30 Apr 2024 09:07:20 +1000 Subject: [PATCH] MAINT: Update anaconda, README, and bibtex style (#23) * 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 --- .github/workflows/cache.yml | 2 +- .github/workflows/ci.yml | 16 ++++++++-------- .github/workflows/linkcheck.yml | 2 +- .github/workflows/publish.yml | 2 +- README.md | 17 +++++++++++++++-- environment.yml | 2 +- lectures/_config.yml | 1 + lectures/bayes_nonconj.md | 15 +++++++-------- 8 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 72ba8a3..390aa60 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 351aac5..c730234 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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} diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml index 00c886a..08df8d9 100644 --- a/.github/workflows/linkcheck.yml +++ b/.github/workflows/linkcheck.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 23ef5c5..34e4234 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 diff --git a/README.md b/README.md index b832d65..811b681 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/environment.yml b/environment.yml index 8571e57..ef4c3bf 100644 --- a/environment.yml +++ b/environment.yml @@ -3,7 +3,7 @@ channels: - default dependencies: - python=3.11 - - anaconda=2023.09 + - anaconda=2024.02 - pip - pip: - jupyter-book==0.15.1 diff --git a/lectures/_config.yml b/lectures/_config.yml index c4003d1..9535dd5 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -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], diff --git a/lectures/bayes_nonconj.md b/lectures/bayes_nonconj.md index 6c72a73..0443499 100644 --- a/lectures/bayes_nonconj.md +++ b/lectures/bayes_nonconj.md @@ -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. @@ -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 `. +We compare computed posteriors with ones associated with a conjugate prior as described in {doc}`the quantecon lecture `. ### Analytical Posterior @@ -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, $$ @@ -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 @@ -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 @@ -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]\\