Skip to content

Commit 3654d58

Browse files
committed
Merge wasm into wasm_pr2_business_cycle
2 parents 8052ad0 + c84c821 commit 3654d58

File tree

11 files changed

+88
-82
lines changed

11 files changed

+88
-82
lines changed

lectures/ar1_processes.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ jupytext:
33
text_representation:
44
extension: .md
55
format_name: myst
6+
format_version: 0.13
7+
jupytext_version: 1.16.1
68
kernelspec:
7-
display_name: Python 3
9+
display_name: Python 3 (ipykernel)
810
language: python
911
name: python3
1012
---
@@ -40,7 +42,7 @@ partly because they help us understand important concepts.
4042

4143
Let's start with some imports:
4244

43-
```{code-cell} ipython
45+
```{code-cell} ipython3
4446
import numpy as np
4547
import matplotlib.pyplot as plt
4648
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
@@ -160,15 +162,15 @@ The following code uses these facts to track the sequence of marginal distributi
160162

161163
The parameters are
162164

163-
```{code-cell} python3
165+
```{code-cell} ipython3
164166
a, b, c = 0.9, 0.1, 0.5
165167
166168
mu, v = -3.0, 0.6 # initial conditions mu_0, v_0
167169
```
168170

169171
Here's the sequence of distributions:
170172

171-
```{code-cell} python3
173+
```{code-cell} ipython3
172174
from scipy.stats import norm
173175
174176
sim_length = 10
@@ -188,8 +190,6 @@ ax.legend(bbox_to_anchor=[1.05,1],loc=2,borderaxespad=1)
188190
plt.show()
189191
```
190192

191-
192-
193193
## Stationarity and asymptotic stability
194194

195195
When we use models to study the real world, it is generally preferable that our
@@ -206,7 +206,7 @@ Notice that, in the figure above, the sequence $\{ \psi_t \}$ seems to be conver
206206

207207
This is even clearer if we project forward further into the future:
208208

209-
```{code-cell} python3
209+
```{code-cell} ipython3
210210
def plot_density_seq(ax, mu_0=-3.0, v_0=0.6, sim_length=40):
211211
mu, v = mu_0, v_0
212212
for t in range(sim_length):
@@ -225,7 +225,7 @@ Moreover, the limit does not depend on the initial condition.
225225

226226
For example, this alternative density sequence also converges to the same limit.
227227

228-
```{code-cell} python3
228+
```{code-cell} ipython3
229229
fig, ax = plt.subplots()
230230
plot_density_seq(ax, mu_0=4.0)
231231
plt.show()
@@ -260,7 +260,7 @@ t \to \infty
260260

261261
We can confirm this is valid for the sequence above using the following code.
262262

263-
```{code-cell} python3
263+
```{code-cell} ipython3
264264
fig, ax = plt.subplots()
265265
plot_density_seq(ax, mu_0=4.0)
266266
@@ -406,7 +406,7 @@ Confirm this by simulation at a range of $k$ using the default parameters from t
406406

407407
Here is one solution:
408408

409-
```{code-cell} python3
409+
```{code-cell} ipython3
410410
from scipy.special import factorial2
411411
412412
def sample_moments_ar1(k, m=100_000, mu_0=0.0, sigma_0=1.0, seed=1234):

lectures/eigen_II.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.14.4
7+
jupytext_version: 1.16.1
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python

lectures/french_rev.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.16.2
7+
jupytext_version: 1.16.1
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
@@ -61,13 +61,20 @@ This lecture uses data from three spreadsheets assembled by {cite}`sargent_velde
6161
* [datasets/dette.xlsx](https://github.com/QuantEcon/lecture-python-intro/blob/main/lectures/datasets/dette.xlsx)
6262
* [datasets/assignat.xlsx](https://github.com/QuantEcon/lecture-python-intro/blob/main/lectures/datasets/assignat.xlsx)
6363

64+
```{code-cell} ipython3
65+
!pip install openpyxl requests
66+
```
67+
6468
```{code-cell} ipython3
6569
import numpy as np
6670
import pandas as pd
71+
import pyodide_http
6772
import matplotlib.pyplot as plt
73+
from io import BytesIO
74+
import requests
6875
plt.rcParams.update({'font.size': 12})
6976
70-
base_url = 'https://github.com/QuantEcon/lecture-python-intro/raw/'\
77+
base_url = 'https://raw.githubusercontent.com/QuantEcon/lecture-python-intro/'\
7178
+ 'main/lectures/datasets/'
7279
7380
fig_3_url = f'{base_url}fig_3.xlsx'
@@ -90,13 +97,11 @@ These graphs show that during the 18th century
9097
but were substantially less than government expenditures during wars
9198
* In France, even in peace time, tax revenues were substantially less than government expenditures
9299

93-
94-
95100
```{code-cell} ipython3
96101
---
97102
mystnb:
98103
figure:
99-
caption: "Military Spending in Britain and France"
104+
caption: Military Spending in Britain and France
100105
name: fr_fig4
101106
---
102107
# Read the data from Excel file
@@ -139,16 +144,15 @@ during those four wars.
139144

140145
A remarkable aspect of figure {numref}`fr_fig4` is that despite having a population less than half of France's, Britain was able to finance military expenses of about the same amounts as France's.
141146

142-
This testifies to Britain's having created state institutions that could sustain high tax collections, government spending , and government borrowing. See {cite}`north1989`.
147+
This testifies to Britain's having created state institutions that could sustain high tax collections, government spending , and government borrowing. See {cite}`north1989`.
143148

144149
```{code-cell} ipython3
145150
---
146151
mystnb:
147152
figure:
148-
caption: "Government Expenditures and Tax Revenues in Britain"
153+
caption: Government Expenditures and Tax Revenues in Britain
149154
name: fr_fig2
150155
---
151-
152156
# Read the data from Excel file
153157
data2 = pd.read_excel(dette_url, sheet_name='Militspe', usecols='M:X',
154158
skiprows=7, nrows=102, header=None)
@@ -178,7 +182,6 @@ plt.tight_layout()
178182
plt.show()
179183
```
180184

181-
182185
Figures {numref}`fr_fig2` and {numref}`fr_fig3` summarize British and French government fiscal policies during the century before the start of the French Revolution in 1789.
183186

184187

@@ -224,10 +227,9 @@ Next we'll plot data on debt service costs as fractions of government revenues i
224227
---
225228
mystnb:
226229
figure:
227-
caption: "Ratio of debt service to taxes, Britain and France"
230+
caption: Ratio of debt service to taxes, Britain and France
228231
name: fr_fig1
229232
---
230-
231233
# Read the data from the Excel file
232234
data1 = pd.read_excel(dette_url, sheet_name='Debt',
233235
usecols='R:S', skiprows=5, nrows=99, header=None)
@@ -265,7 +267,6 @@ Figure {numref}`fr_fig1` shows that interest payments on government debt (i.e.,
265267

266268
But as we'll see in our next graph, on the eve of the French Revolution in 1788, the fiscal *law of gravity* that worked so well in Britain did not working very well in France.
267269

268-
269270
```{code-cell} ipython3
270271
# Read the data from the Excel file
271272
data1 = pd.read_excel(fig_3_url, sheet_name='Sheet1',
@@ -278,7 +279,7 @@ data1.replace(0, np.nan, inplace=True)
278279
---
279280
mystnb:
280281
figure:
281-
caption: "Government Spending and Tax Revenues in France"
282+
caption: Government Spending and Tax Revenues in France
282283
name: fr_fig3
283284
---
284285
# Plot the data
@@ -430,7 +431,7 @@ The next figure shows this
430431
---
431432
mystnb:
432433
figure:
433-
caption: "Index of real per capital revenues, France"
434+
caption: Index of real per capital revenues, France
434435
name: fr_fig5
435436
---
436437
# Read data from Excel file
@@ -466,7 +467,7 @@ amounts during the period form 1789 to 1799.
466467
---
467468
mystnb:
468469
figure:
469-
caption: "Spending (blue) and Revenues (orange), (real values)"
470+
caption: Spending (blue) and Revenues (orange), (real values)
470471
name: fr_fig11
471472
---
472473
# Read data from Excel file
@@ -512,7 +513,7 @@ of goods and services, including military goods and soldiers' pay.
512513
---
513514
mystnb:
514515
figure:
515-
caption: "Revenues raised by printing paper money notes"
516+
caption: Revenues raised by printing paper money notes
516517
name: fr_fig24
517518
---
518519
# Read data from Excel file
@@ -575,7 +576,7 @@ Note that we use a log scale because the price level rose so much.
575576
---
576577
mystnb:
577578
figure:
578-
caption: "Price Level and Price of Gold (log scale)"
579+
caption: Price Level and Price of Gold (log scale)
579580
name: fr_fig9
580581
---
581582
# Read the data from Excel file
@@ -644,7 +645,7 @@ nearly met in one of these episodes than in the other two.
644645
---
645646
mystnb:
646647
figure:
647-
caption: "Real balances of assignats (in gold and goods)"
648+
caption: Real balances of assignats (in gold and goods)
648649
name: fr_fig8
649650
---
650651
# Read the data from Excel file
@@ -712,8 +713,10 @@ def fit(x, y):
712713

713714
```{code-cell} ipython3
714715
# Load data
715-
caron = np.load('datasets/caron.npy')
716-
nom_balances = np.load('datasets/nom_balances.npy')
716+
caron_response = requests.get(base_url + 'caron.npy')
717+
nom_balances_response = requests.get(base_url + 'nom_balances.npy')
718+
caron = np.load(BytesIO(caron_response.content))
719+
nom_balances = np.load(BytesIO(nom_balances_response.content))
717720
718721
infl = np.concatenate(([np.nan],
719722
-np.log(caron[1:63, 1] / caron[0:62, 1])))
@@ -736,7 +739,7 @@ a3_rev, b3_rev = fit(infl[44:63], bal[44:63])
736739
---
737740
mystnb:
738741
figure:
739-
caption: "Inflation and Real Balances"
742+
caption: Inflation and Real Balances
740743
name: fr_fig104
741744
---
742745
plt.figure()
@@ -791,7 +794,7 @@ a3_rev, b3_rev = fit(infl[44:63], bal[44:63])
791794
---
792795
mystnb:
793796
figure:
794-
caption: "Inflation and Real Balances"
797+
caption: Inflation and Real Balances
795798
name: fr_fig104b
796799
---
797800
plt.figure()
@@ -822,7 +825,7 @@ line.
822825
---
823826
mystnb:
824827
figure:
825-
caption: "Inflation and Real Balances"
828+
caption: Inflation and Real Balances
826829
name: fr_fig104c
827830
---
828831
plt.figure()
@@ -867,7 +870,7 @@ line.
867870
---
868871
mystnb:
869872
figure:
870-
caption: "Inflation and Real Balances"
873+
caption: Inflation and Real Balances
871874
name: fr_fig104d
872875
---
873876
plt.figure()
@@ -912,7 +915,7 @@ Cagan {cite}`Cagan`.
912915
---
913916
mystnb:
914917
figure:
915-
caption: "Inflation and Real Balances"
918+
caption: Inflation and Real Balances
916919
name: fr_fig104e
917920
---
918921
plt.figure()
@@ -946,7 +949,7 @@ period of the hyperinflation.
946949
---
947950
mystnb:
948951
figure:
949-
caption: "Inflation and Real Balances"
952+
caption: Inflation and Real Balances
950953
name: fr_fig104f
951954
---
952955
plt.figure()
@@ -993,4 +996,4 @@ This lecture sets the stage for studying theories of inflation and the govern
993996

994997
A *monetarist theory of the price level* is described in this quantecon lecture {doc}`cagan_ree`.
995998

996-
That lecture sets the stage for these quantecon lectures {doc}`money_inflation` and {doc}`unpleasant`.
999+
That lecture sets the stage for these quantecon lectures {doc}`money_inflation` and {doc}`unpleasant`.

lectures/heavy_tails.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
1919
```{code-cell} ipython3
2020
:tags: [hide-output]
2121
22-
!pip install --upgrade yfinance pandas_datareader
22+
!pip install yfinance pandas_datareader
2323
```
2424

2525
We use the following imports.
@@ -30,11 +30,13 @@ import numpy as np
3030
import yfinance as yf
3131
import pandas as pd
3232
import statsmodels.api as sm
33+
import pyodide_http
3334
3435
from pandas_datareader import wb
3536
from scipy.stats import norm, cauchy
3637
from pandas.plotting import register_matplotlib_converters
3738
register_matplotlib_converters()
39+
pyodide_http.patch_all()
3840
```
3941

4042
## Overview

0 commit comments

Comments
 (0)