Skip to content

Commit

Permalink
Merge branch 'main' into fix-codefromfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcky committed Apr 15, 2021
2 parents 8b85838 + 19dab39 commit 194de0e
Show file tree
Hide file tree
Showing 26 changed files with 1,762 additions and 164 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Project [using jupyter-book]
name: Build HTML [using jupyter-book]
on: [push]
jobs:
tests:
Expand All @@ -14,17 +14,29 @@ jobs:
miniconda-version: 'latest'
python-version: 3.8
environment-file: environment.yml
activate-environment: lecture-python-advanced.myst
activate-environment: quantecon
- name: Display Conda Environment Versions
shell: bash -l {0}
run: conda list
- name: Display Pip Versions
shell: bash -l {0}
run: pip list
# - name: Download "build" folder (cache)
# uses: dawidd6/action-download-artifact@v2
# with:
# workflow: publish.yml
# branch: main
# name: build-cache
# path: _build
- name: Build HTML
shell: bash -l {0}
run: |
jb build lectures --path-output ./
- name: Save Build as Artifact
uses: actions/upload-artifact@v1
with:
name: _build
path: _build
- name: Preview Deploy to Netlify
uses: nwtgck/actions-netlify@v1.1
with:
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build & Publish to GH-PAGES
on:
push:
tags:
- 'publish*'
jobs:
publish:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Anaconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
auto-activate-base: true
miniconda-version: 'latest'
python-version: 3.8
environment-file: environment.yml
activate-environment: quantecon
- name: Display Conda Environment Versions
shell: bash -l {0}
run: conda list
- name: Display Pip Versions
shell: bash -l {0}
run: pip list
- name: Build HTML
shell: bash -l {0}
run: |
jb build lectures --path-output ./
- name: Build Download Notebooks (sphinx-tojupyter)
shell: bash -l {0}
run: |
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter
zip -r download-notebooks.zip _build/jupyter
- uses: actions/upload-artifact@v2
with:
name: download-notebooks
path: download-notebooks.zip
- name: Copy Download Notebooks for GH-PAGES
shell: bash -l {0}
run: |
mkdir _build/html/_notebooks
cp _build/jupyter/*.ipynb _build/html/_notebooks
- name: Deploy website to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/html/
cname: python-advanced.quantecon.org
- name: Upload "_build" folder (cache)
uses: actions/upload-artifact@v2
with:
name: build-cache
path: _build
- name: Prepare lecture-python-advanced.notebooks sync
shell: bash -l {0}
run: |
mkdir -p _build/lecture-python-advanced.notebooks
cp -a _notebook_repo/. _build/lecture-python-advanced.notebooks
cp _build/jupyter/*.ipynb _build/lecture-python-advanced.notebooks
ls -a _build/lecture-python-advanced.notebooks
- name: Commit latest notebooks to lecture-python-advanced.notebooks
uses: cpina/github-action-push-to-another-repository@master
env:
API_TOKEN_GITHUB: ${{ secrets.QUANTECON_SERVICES_PAT }}
with:
source-directory: '_build/lecture-python-advanced.notebooks/'
destination-repository-username: 'QuantEcon'
destination-repository-name: 'lecture-python-advanced.notebooks'
commit-message: 'auto publishing updates to notebooks'
destination-github-username: 'quantecon-services'
user-email: services@quantecon.org
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# lecture-python-advanced.myst
Migration to Myst (Source files for https://python-advanced.quantecon.org)

# Current Hosting

https://5ff577b6c5ec3f9de6b87508--wonderful-lalande-528d1c.netlify.app/intro.html
21 changes: 12 additions & 9 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: lecture-python-advanced.myst
name: quantecon
channels:
- default
dependencies:
- pip
- python=3.8
- anaconda=2020.07
- anaconda=2020.11
- pip
- pip:
- jupytext
- jupyter-book
- quantecon
- joblib
- git+https://github.com/QuantEcon/quantecon-book-theme
- git+https://github.com/executablebooks/sphinx-multitoc-numbering.git
- interpolation
- sphinx-multitoc-numbering
- quantecon-book-theme
- sphinx-tojupyter
- sphinxext-rediraffe
- sphinx-exercise
- jupytext
- ghp-import
- jupinx

7 changes: 6 additions & 1 deletion lectures/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ sphinx:
config:
html_theme: quantecon_book_theme
html_static_path: ['_static']
mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
mathjax_config:
TeX:
Macros:
"argmax" : "arg\\,max"
"argmin" : "arg\\,min"
mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
1 change: 1 addition & 0 deletions lectures/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- file: additive_functionals
- file: lu_tricks
- file: classical_filtering
- file: knowing_forecasts_of_others

- part: Asset Pricing and Finance
chapters:
Expand Down
6 changes: 4 additions & 2 deletions lectures/additive_functionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -1265,9 +1265,11 @@ These probability density functions help us understand mechanics underlying the

### Multiplicative Martingale as Likelihood Ratio Process

{doc}`This lecture <likelihood_ratio_process>` studies **likelihood processes** and **likelihood ratio processes**.
[This lecture](https://python.quantecon.org/likelihood_ratio_process.html) studies **likelihood processes**
and **likelihood ratio processes**.

A **likelihood ratio process** is a multiplicative martingale with mean unity.

Likelihood ratio processes exhibit the peculiar property that naturally also appears in {doc}`this lecture <likelihood_ratio_process>`.
Likelihood ratio processes exhibit the peculiar property that naturally also appears
[here](https://python.quantecon.org/likelihood_ratio_process.html).

15 changes: 0 additions & 15 deletions lectures/amss.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@ kernelspec:
:depth: 2
```

**Software Requirement:**

This lecture requires the use of some older software versions to run. If
you would like to execute this lecture please download the following
<a href=_static/downloads/amss_environment.yml download>amss_environment.yml</a>
file. This specifies the software required and an environment can be
created using [conda](https://docs.conda.io/en/latest/):

Open a terminal:

```{code-block} bash
conda env create --file amss_environment.yml
conda activate amss
```

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

```{code-cell} ipython
Expand Down
15 changes: 0 additions & 15 deletions lectures/amss2.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@ kernelspec:
:depth: 2
```

**Software Requirement:**

This lecture requires the use of some older software versions to run. If
you would like to execute this lecture please download the following
<a href=_static/downloads/amss_environment.yml download>amss_environment.yml</a>
file. This specifies the software required and an environment can be
created using [conda](https://docs.conda.io/en/latest/):

Open a terminal:

```{code-block} bash
conda env create --file amss_environment.yml
conda activate amss
```

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

```{code-cell} ipython
Expand Down
15 changes: 0 additions & 15 deletions lectures/amss3.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@ kernelspec:
:depth: 2
```

**Software Requirement:**

This lecture requires the use of some older software versions to run. If
you would like to execute this lecture please download the following
<a href=_static/downloads/amss_environment.yml download>amss_environment.yml</a>
file. This specifies the software required and an environment can be
created using [conda](https://docs.conda.io/en/latest/):

Open a terminal:

```{code-block} bash
conda env create --file amss_environment.yml
conda activate amss
```

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

```{code-cell} ipython
Expand Down
4 changes: 2 additions & 2 deletions lectures/arellano.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ import numpy as np
import quantecon as qe
import random
from numba import jit, jitclass, int64, float64
from numba import jit, int64, float64
from numba.experimental import jitclass
%matplotlib inline
```

Expand Down
11 changes: 4 additions & 7 deletions lectures/black_litterman.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ sample = excess_return.rvs(T)
w = np.linalg.solve(δ * Σ_est, μ_est)
fig, ax = plt.subplots(figsize=(8, 5))
ax.set_title('Mean-variance portfolio weights recommendation \
and the market portfolio')
ax.set_title('Mean-variance portfolio weights recommendation and the market portfolio')
ax.plot(np.arange(N)+1, w, 'o', c='k', label='$w$ (mean-variance)')
ax.plot(np.arange(N)+1, w_m, 'o', c='r', label='$w_m$ (market portfolio)')
ax.vlines(np.arange(N)+1, 0, w, lw=1)
Expand All @@ -219,7 +218,7 @@ Black and Litterman's responded to this situation in the following way:
- They want to continue to allow the customer to express his or her
risk tolerance by setting $\delta$.
- Leaving $\Sigma$ at its maximum-likelihood value, they push
$\mu$ away from its maximum value in a way designed to make
$\mu$ away from its maximum-likelihood value in a way designed to make
portfolio choices that are more plausible in terms of conforming to
what most people actually do.

Expand Down Expand Up @@ -314,8 +313,7 @@ d_m = r_m / σ_m
μ_m = (d_m * Σ_est @ w_m).reshape(N, 1)
fig, ax = plt.subplots(figsize=(8, 5))
ax.set_title(r'Difference between $\hat{\mu}$ (estimate) and \
$\mu_{BL}$ (market implied)')
ax.set_title(r'Difference between $\hat{\mu}$ (estimate) and $\mu_{BL}$ (market implied)')
ax.plot(np.arange(N)+1, μ_est, 'o', c='k', label='$\hat{\mu}$')
ax.plot(np.arange(N)+1, μ_m, 'o', c='r', label='$\mu_{BL}$')
ax.vlines(np.arange(N) + 1, μ_m, μ_est, lw=1)
Expand Down Expand Up @@ -418,8 +416,7 @@ def BL_plot(τ):
ax[0].vlines(np.arange(N)+1, μ_m, μ_est, lw=1)
ax[0].axhline(0, c='k', ls='--')
ax[0].set(xlim=(0, N+1), xlabel='Assets',
title=r'Relationship between $\hat{\mu}$, \
$\mu_{BL}$and$\tilde{\mu}$')
title=r'Relationship between $\hat{\mu}$, $\mu_{BL}$, and $ \tilde{\mu}$')
ax[0].xaxis.set_ticks(np.arange(1, N+1, 1))
ax[0].legend(numpoints=1)
Expand Down
16 changes: 8 additions & 8 deletions lectures/cattle_cycles.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,15 @@ econ2.irf(ts_length=25, shock=shock_demand)
econ3.irf(ts_length=25, shock=shock_demand)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4))
ax1.plot(econ1.c_irf, label='$\\rho=0.6$')
ax1.plot(econ2.c_irf, label='$\\rho=1$')
ax1.plot(econ3.c_irf, label='$\\rho=0$')
ax1.plot(econ1.c_irf, label=r'$\rho=0.6$')
ax1.plot(econ2.c_irf, label=r'$\rho=1$')
ax1.plot(econ3.c_irf, label=r'$\rho=0$')
ax1.set_title('Consumption response to demand shock')
ax1.legend()
ax2.plot(econ1.k_irf[:, 0], label='$\\rho=0.6$')
ax2.plot(econ2.k_irf[:, 0], label='$\\rho=1$')
ax2.plot(econ3.k_irf[:, 0], label='$\\rho=0$')
ax2.plot(econ1.k_irf[:, 0], label=r'$\rho=0.6$')
ax2.plot(econ2.k_irf[:, 0], label=r'$\rho=1$')
ax2.plot(econ3.k_irf[:, 0], label=r'$\rho=0$')
ax2.set_title('Breeding stock response to demand shock')
ax2.legend()
plt.show()
Expand Down Expand Up @@ -393,11 +393,11 @@ total3_irf = econ3.k_irf[:, 0] + g * econ3.k_irf[:, 1] + g * econ3.k_irf[:, 2]
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4))
ax1.plot(econ1.k_irf[:, 0], label='Breeding Stock')
ax1.plot(total1_irf, label='Total Stock')
ax1.set_title('$\\rho=0.6$')
ax1.set_title(r'$\rho=0.6$')
ax2.plot(econ3.k_irf[:, 0], label='Breeding Stock')
ax2.plot(total3_irf, label='Total Stock')
ax2.set_title('$\\rho=0$')
ax2.set_title(r'$\rho=0$')
plt.show()
```

Expand Down
6 changes: 3 additions & 3 deletions lectures/classical_filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ or
```{math}
:label: eq_55
x_t = \sum^{t-1}_{j=0} L^{-1}_{t,t-j}\, \varepsilon_{t-j}\
x_t = \sum^{t-1}_{j=0} L^{-1}_{t,t-j}\, \varepsilon_{t-j}
```

where $L^{-1}_{i,j}$ denotes the $i,j$ element of $L^{-1}$.
Expand Down Expand Up @@ -223,7 +223,7 @@ $$

### Implementation

Here's the code that computes solutions to LQ control and filtering problems using the methods described here and in :doc: lu_tricks.
Here's the code that computes solutions to LQ control and filtering problems using the methods described here and in {doc}`lu_tricks <lu_tricks>`.

```{code-cell} python3
:file: _static/lecture_specific/lu_tricks/control_and_filter.py
Expand Down Expand Up @@ -256,7 +256,7 @@ h = 0.0
example = LQFilter(d, h, y_m, r=d)
```

The Wold representation is computed by example.coefficients_of_c().
The Wold representation is computed by `example.coeffs_of_c()`.

Let's check that it "flips roots" as required

Expand Down
12 changes: 7 additions & 5 deletions lectures/cons_news.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ y_{t+1} - y_t = a_{t+1} - \beta a_t \quad
```

where $\{a_t\}$ is another i.i.d. normally distributed scalar
process, with means of zero and now variances $\sigma_a^2$.
process, with means of zero and now variances $\sigma_a^2 > \sigma_\epsilon^2$.

The two i.i.d. shock variances are related by

Expand Down Expand Up @@ -175,7 +175,7 @@ Using calculations in the {doc}`quantecon lecture <classical_filtering>`, where
$z \in C$ is a complex variable, the covariance generating
function $g (z) =
\sum_{j=-\infty}^\infty g_j z^j$
of the $\{(y_t - y_{t-1})\}$ process equals
of the $\{y_t - y_{t-1}\}$ process equals

$$
g(z) = \sigma_\epsilon^2 h(z) h(z^{-1}) = \beta^{-2} \sigma_\epsilon^2 > \sigma_\epsilon^2 ,
Expand Down Expand Up @@ -420,9 +420,11 @@ exactly the same histories of nonfinancial income.

The consumer with information associated with representation {eq}`eqn_1`
responds to each shock $\epsilon_{t+1}$ by leaving his consumption
unaltered and **saving** all of $a_{t+1}$ in anticipation of the
permanently increased taxes that he will bear to pay for the addition
$a_{t+1}$ to his time $t+1$ nonfinancial income.
unaltered and **saving** all of $\epsilon_{t+1}$ in anticipation of the
permanently increased taxes that he will bear in order to service the permanent interest payments on the risk-free
bonds that the government has
presumably issued to pay for the one-time addition
$\epsilon_{t+1}$ to his time $t+1$ nonfinancial income.

The consumer with information associated with representation {eq}`eqn_2`
responds to a shock $a_{t+1}$ by increasing his consumption by
Expand Down
Loading

0 comments on commit 194de0e

Please sign in to comment.