From 46c55134a0185da8f8abc98a8f16d3652df4d51d Mon Sep 17 00:00:00 2001 From: mmcky Date: Sat, 10 Dec 2022 21:09:34 +1100 Subject: [PATCH 1/9] MAINT: tidy up two_actions --- lectures/two_auctions.md | 59 ++++------------------------------------ 1 file changed, 6 insertions(+), 53 deletions(-) diff --git a/lectures/two_auctions.md b/lectures/two_auctions.md index e1947c508..1b5df082f 100644 --- a/lectures/two_auctions.md +++ b/lectures/two_auctions.md @@ -3,10 +3,8 @@ jupytext: text_representation: extension: .md format_name: myst - format_version: 0.13 - jupytext_version: 1.10.3 kernelspec: - display_name: Python 3 (ipykernel) + display_name: Python 3 language: python name: python3 --- @@ -29,16 +27,13 @@ We'll also learn about and apply a * Revenue Equivalent Theorem - We recommend watching this video about second price auctions by Anders Munk-Nielsen: ```{youtube} qwWk_Bqtue8 ``` - and - ```{youtube} eYTGQCGpmXI ``` @@ -46,15 +41,8 @@ Anders Munk-Nielsen put his code [on GitHub](https://github.com/GamEconCph/Lectu Much of our Python code below is based on his. - - - -+++ - ## First-Price Sealed-Bid Auction (FPSB) -+++ - **Protocols:** * A single good is auctioned. @@ -110,16 +98,10 @@ $$ y_{i} = \max_{j \neq i} v_{j} $$ (eq:optbid2) - - A proof for this assertion is available at the [Wikepedia page](https://en.wikipedia.org/wiki/Vickrey_auction) about Vickrey auctions -+++ - ## Second-Price Sealed-Bid Auction (SPSB) -+++ - **Protocols:** In a second-price sealed-bid (SPSB) auction, the winner pays the second-highest bid. ## Characterization of SPSB Auction @@ -128,15 +110,10 @@ In a SPSB auction bidders optimally choose to bid their values. Formally, a dominant strategy profile in a SPSB auction with a single, indivisible item has each bidder bidding its value. -A proof is provided at [the Wikepedia - page](https://en.wikipedia.org/wiki/Vickrey_auction) about Vickrey auctions - -+++ +A proof is provided at [the Wikepedia page](https://en.wikipedia.org/wiki/Vickrey_auction) about Vickrey auctions ## Uniform Distribution of Private Values -+++ - We assume valuation $v_{i}$ of bidder $i$ is distributed $v_{i} \stackrel{\text{i.i.d.}}{\sim} U(0,1)$. Under this assumption, we can analytically compute probability distributions of prices bid in both FPSB and SPSB. @@ -147,12 +124,8 @@ We can use our simulation to illustrate a **Revenue Equivalence Theorem** th To read about the revenue equivalence theorem, see [this Wikepedia page](https://en.wikipedia.org/wiki/Revenue_equivalence) -+++ - ## Setup -+++ - There are $n$ bidders. Each bidder knows that there are $n-1$ other bidders. @@ -173,7 +146,7 @@ $$ and the PDF of $y_i$ is $\tilde{f}_{n-1}(y) = (n-1)y^{n-2}$. -Then bidder $i$'s optimal bid in a **FPSB** auction is: +Then bidder $i$'s optimal bid in a **FPSB** auction is: $$ \begin{aligned} @@ -188,8 +161,6 @@ $$ In a **SPSB**, it is optimal for bidder $i$ to bid $v_i$. -+++ - ## Python Code ```{code-cell} ipython3 @@ -224,7 +195,7 @@ b_star = lambda vi,N :((N-1)/N) * vi b = b_star(v,N) ``` -We compute and sort bid price distributions that emerge under both FPSB and SPSB. +We compute and sort bid price distributions that emerge under both FPSB and SPSB. ```{code-cell} ipython3 idx = np.argsort(v, axis=0) # Biders' values are sorted in ascending order in each auction. @@ -271,12 +242,8 @@ sns.despine() ## Revenue Equivalence Theorem -+++ - We now compare FPSB and a SPSB auctions from the point of view of the revenues that a seller can expect to acquire. - - **Expected Revenue FPSB:** The winner with valuation $y$ pays $\frac{n-1}{n}*y$, where n is the number of bidders. @@ -305,8 +272,6 @@ $$ \end{aligned} $$ -+++ - Thus, while probability distributions of winning bids typically differ across the two types of auction, we deduce that expected payments are identical in FPSB and SPSB. ```{code-cell} ipython3 @@ -325,7 +290,7 @@ ax.set_ylabel('Density') sns.despine() ``` -**
Summary of FPSB and SPSB results with uniform distribution on $[0,1]$
** +**Summary of FPSB and SPSB results with uniform distribution on $[0,1]$** | Auction: Sealed-Bid | First-Price | Second-Price | | :-----------------------: | :----------------------------------: | :-------------------------------------: | @@ -336,8 +301,6 @@ sns.despine() | Bayesian Nash equilibrium | Bidder $i$ bids $\frac{n-1}{n}v_{i}$ | Bidder $i$ truthfully bids $v_{i}$ | | Auctioneer's revenue | $\frac {n-1}{n+1}$ | $\frac {n-1}{n+1}$ | -+++ - **Detour: Computing a Bayesian Nash Equibrium for FPSB** The Revenue Equivalence Theorem lets us an optimal bidding strategy for a FPSB auction from outcomes of a SPSB auction. @@ -354,12 +317,8 @@ $$ It follows that an optimal bidding strategy in a FPSB auction is $b(v_{i}) = \mathbf{E}_{y_{i}}[y_{i} | y_{i} < v_{i}]$. -+++ - ## Calculation of Bid Price in FPSB -+++ - In equations {eq}`eq:optbid1` and {eq}`eq:optbid1`, we displayed formulas for optimal bids in a symmetric Bayesian Nash Equilibrium of a FPSB auction. @@ -371,10 +330,8 @@ where - $v_{i} = $ value of bidder $i$ - $y_{i} = $: maximum value of all bidders except $i$, i.e., $y_{i} = \max_{j \neq i} v_{j}$ - Above, we computed an optimal bid price in a FPSB auction analytically for a case in which private values are uniformly distributed. - For most probability distributions of private values, analytical solutions aren't easy to compute. Instead, we can compute bid prices in FPSB auctions numerically as functions of the distribution of private values. @@ -519,9 +476,7 @@ ax.set_ylabel('Density') sns.despine() ``` -## 5 Code Summary - -+++ +## Code Summary We assemble the functions that we have used into a Python class @@ -646,8 +601,6 @@ chi_squ_case.plot_winner_payment_distribution() ## References -+++ - 1. Wikipedia for FPSB: https://en.wikipedia.org/wiki/First-price_sealed-bid_auction 2. Wikipedia for SPSB: https://en.wikipedia.org/wiki/Vickrey_auction 3. Chandra Chekuri's lecture note for algorithmic game theory: http://chekuri.cs.illinois.edu/teaching/spring2008/Lectures/scribed/Notes20.pdf From d7ff2cfd1e5820e83a6d0d0408e21b05a29c84bc Mon Sep 17 00:00:00 2001 From: mmcky Date: Sat, 10 Dec 2022 21:35:05 +1100 Subject: [PATCH 2/9] fix space in code --- lectures/two_auctions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/two_auctions.md b/lectures/two_auctions.md index 1b5df082f..ee1a96c4e 100644 --- a/lectures/two_auctions.md +++ b/lectures/two_auctions.md @@ -173,7 +173,7 @@ import scipy.interpolate as interp # for plots plt.rcParams.update({"text.usetex": True, 'font.size': 14}) -colors = plt. rcParams['axes.prop_cycle'].by_key()['color'] +colors = plt.rcParams['axes.prop_cycle'].by_key()['color'] # ensure the notebook generate the same randomess np.random.seed(1337) From 4dbe3e43020d23ba609ff8ac298ccac3b5403cc3 Mon Sep 17 00:00:00 2001 From: mmcky Date: Sat, 10 Dec 2022 21:52:55 +1100 Subject: [PATCH 3/9] fix lambda syntax --- lectures/two_auctions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/two_auctions.md b/lectures/two_auctions.md index ee1a96c4e..88066351b 100644 --- a/lectures/two_auctions.md +++ b/lectures/two_auctions.md @@ -191,7 +191,7 @@ v = np.random.uniform(0,1,(N,R)) # BNE in first-price sealed bid -b_star = lambda vi,N :((N-1)/N) * vi +b_star = lambda vi,N: ((N-1)/N) * vi b = b_star(v,N) ``` From b9c67cde69485d0e7417fd3a5b34b182237eda51 Mon Sep 17 00:00:00 2001 From: mmcky Date: Sat, 10 Dec 2022 21:58:29 +1100 Subject: [PATCH 4/9] check LaTeX --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e9e074e9..6b15aea98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,6 +79,9 @@ jobs: jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going mkdir -p _build/html/_notebooks cp -u _build/jupyter/*.ipynb _build/html/_notebooks + - name: Check LaTeX + shell: bash -l {0} + run: latex --version - name: Build PDF from LaTeX shell: bash -l {0} run: | From 7ec097cd24eaaff5928242be4a2132959c6ffc83 Mon Sep 17 00:00:00 2001 From: mmcky Date: Sat, 10 Dec 2022 22:16:04 +1100 Subject: [PATCH 5/9] add dvipng --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b15aea98..ca2fb4704 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,8 @@ jobs: texlive-fonts-extra \ texlive-xetex \ latexmk \ - xindy + xindy \ + dvipng - name: Display Conda Environment Versions shell: bash -l {0} run: conda list From 4aa2ea8b8ad0b0e90af230b158115eece383691a Mon Sep 17 00:00:00 2001 From: mmcky Date: Sat, 10 Dec 2022 22:45:35 +1100 Subject: [PATCH 6/9] upload build folder --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca2fb4704..2ce6fd27c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,12 +89,12 @@ jobs: jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going mkdir _build/html/_pdf cp -u _build/latex/*.pdf _build/html/_pdf - - name: Upload Execution Reports (LaTeX) + - name: Upload Build Folder (LaTeX) uses: actions/upload-artifact@v2 if: failure() with: - name: execution-reports - path: _build/latex/reports + name: build-folder-latex + path: _build/ # Final Build of HTML - name: Build HTML shell: bash -l {0} From ed1213d577db1810283966fbed88a91651d1f5ff Mon Sep 17 00:00:00 2001 From: mmcky Date: Sat, 10 Dec 2022 22:47:45 +1100 Subject: [PATCH 7/9] add ghostscript --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ce6fd27c..0482ca13e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,8 @@ jobs: texlive-xetex \ latexmk \ xindy \ - dvipng + dvipng \ + ghostscript - name: Display Conda Environment Versions shell: bash -l {0} run: conda list From ef304d2227c019cd93405ac18c11a862f3841385 Mon Sep 17 00:00:00 2001 From: mmcky Date: Sat, 10 Dec 2022 23:07:31 +1100 Subject: [PATCH 8/9] setup latex before anaconda --- .github/workflows/ci.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0482ca13e..4b9bb61cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,21 +30,6 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - - name: Setup Anaconda - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - auto-activate-base: true - miniconda-version: 'latest' - python-version: 3.9 - environment-file: environment.yml - activate-environment: quantecon - - name: Install Jax and Upgrade CUDA - shell: bash -l {0} - run: | - pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html - pip install --upgrade "numpyro[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html - nvidia-smi - name: Install latex dependencies shell: bash -l {0} run: | @@ -61,6 +46,21 @@ jobs: xindy \ dvipng \ ghostscript + - name: Setup Anaconda + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + auto-activate-base: true + miniconda-version: 'latest' + python-version: 3.9 + environment-file: environment.yml + activate-environment: quantecon + - name: Install Jax and Upgrade CUDA + shell: bash -l {0} + run: | + pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html + pip install --upgrade "numpyro[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html + nvidia-smi - name: Display Conda Environment Versions shell: bash -l {0} run: conda list From ba6c2694d9c1a5122b0bdfc742cee4b67eb82d4c Mon Sep 17 00:00:00 2001 From: mmcky Date: Sun, 11 Dec 2022 12:50:34 +1100 Subject: [PATCH 9/9] remove latex support from ci workflow --- .github/workflows/ci.yml | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b9bb61cf..8aae63ba7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,22 +30,6 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - - name: Install latex dependencies - shell: bash -l {0} - run: | - apt-get -qq update - export DEBIAN_FRONTEND=noninteractive - apt-get install -y tzdata - apt-get install -y \ - texlive-latex-recommended \ - texlive-latex-extra \ - texlive-fonts-recommended \ - texlive-fonts-extra \ - texlive-xetex \ - latexmk \ - xindy \ - dvipng \ - ghostscript - name: Setup Anaconda uses: conda-incubator/setup-miniconda@v2 with: @@ -59,7 +43,6 @@ jobs: shell: bash -l {0} run: | pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html - pip install --upgrade "numpyro[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html nvidia-smi - name: Display Conda Environment Versions shell: bash -l {0} @@ -81,21 +64,18 @@ jobs: jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going mkdir -p _build/html/_notebooks cp -u _build/jupyter/*.ipynb _build/html/_notebooks - - name: Check LaTeX - shell: bash -l {0} - run: latex --version - name: Build PDF from LaTeX shell: bash -l {0} run: | jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going mkdir _build/html/_pdf cp -u _build/latex/*.pdf _build/html/_pdf - - name: Upload Build Folder (LaTeX) + - name: Upload Execution Reports (LaTeX) uses: actions/upload-artifact@v2 if: failure() with: - name: build-folder-latex - path: _build/ + name: execution-reports + path: _build/latex/reports # Final Build of HTML - name: Build HTML shell: bash -l {0}