Skip to content

Commit 1ec45f4

Browse files
authored
Switch to Hint and Note Admonitions (#269)
* swtich to admonitions * update prob_matrix * temporarily change CI run * handle deprecations * replace np.int() * change ci.yml back * adding space
1 parent 1cbe200 commit 1ec45f4

13 files changed

+79
-38
lines changed

lectures/ar1_bayes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,10 @@ Please note how the posterior for $\rho$ has shifted to the right relative to wh
275275
276276
Think about why this happens.
277277
278-
**Hint:** It is connected to how Bayes Law (conditional probability) solves an **inverse problem** by putting high probability on parameter values
278+
```{hint}
279+
It is connected to how Bayes Law (conditional probability) solves an **inverse problem** by putting high probability on parameter values
279280
that make observations more likely.
281+
```
280282
281283
We'll return to this issue after we use `numpyro` to compute posteriors under our two alternative assumptions about the distribution of $y_0$.
282284

lectures/career.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,10 @@ In particular, modulo randomness, reproduce the following figure (where the hori
374374
```{figure} /_static/lecture_specific/career/career_solutions_ex1_py.png
375375
```
376376

377-
Hint: To generate the draws from the distributions $F$ and $G$, use `quantecon.random.draw()`.
377+
```{hint}
378+
:class: dropdown
379+
To generate the draws from the distributions $F$ and $G$, use `quantecon.random.draw()`.
380+
```
378381

379382
```{exercise-end}
380383
```

lectures/cass_koopmans_2.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,10 @@ consumer (also known as a *household*) chooses for itself subject to a budget co
177177
- The representative household and the representative firm are both
178178
**price takers** who believe that prices are not affected by their choices
179179

180-
**Note:** We can think of there being unit measures of identical representative consumers and
180+
```{note}
181+
We can think of there being unit measures of identical representative consumers and
181182
identical representative firms.
183+
```
182184

183185
## Market Structure
184186

@@ -627,9 +629,11 @@ within a competitive equilibrium.
627629
By {eq}`ge1` and {eq}`ge2` this allocation is
628630
identical to the one that solves the consumer's problem.
629631

630-
**Note:** Because budget sets are affected only by relative prices,
632+
```{note}
633+
Because budget sets are affected only by relative prices,
631634
$\{q_0^t\}$ is determined only up to multiplication by a
632635
positive constant.
636+
```
633637

634638
**Normalization:** We are free to choose a $\{q_0^t\}$ that
635639
makes $\lambda=1$ so that we are measuring $q_0^t$ in

lectures/heavy_tails.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,9 @@ If you like you can use the function `qe.rank_size` from the `quantecon` library
622622
Use `np.random.seed(13)` to set the seed.
623623
```
624624

625-
```{exercise}
625+
```{exercise-start}
626626
:label: ht_ex5
627+
```
627628

628629
There is an ongoing argument about whether the firm size distribution should
629630
be modeled as a Pareto distribution or a lognormal distribution (see, e.g.,
@@ -669,9 +670,13 @@ For the seed use `np.random.seed(1234)`.
669670

670671
What differences do you observe?
671672

672-
(Note: a better approach to this problem would be to model firm dynamics and
673+
```{note}
674+
A better approach to this problem would be to model firm dynamics and
673675
try to track individual firms given the current distribution. We will discuss
674-
firm dynamics in later lectures.)
676+
firm dynamics in later lectures.
677+
```
678+
679+
```{exercise-end}
675680
```
676681

677682
## Solutions
@@ -715,6 +720,7 @@ plt.show()
715720

716721
```{solution-start} ht_ex2
717722
:class: dropdown
723+
```
718724

719725
Let $X$ have a Pareto tail with tail index $\alpha$ and let $F$ be its cdf.
720726

@@ -738,8 +744,6 @@ $$
738744
We know that $\int_{\bar x}^\infty x^{r-\alpha-1} x = \infty$ whenever $r - \alpha - 1 \geq -1$.
739745

740746
Since $r \geq \alpha$, we have $\mathbb E X^r = \infty$.
741-
```
742-
743747

744748
```{solution-end}
745749
```

lectures/hoist_failure.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ In particular, if $y_1$ is log normal with parameters $(\mu_1, \sigma_1^2)$ and
124124
$y_2$ is log normal with parameters $(\mu_2, \sigma_2^2)$, then the product $y_1 y_2$ is log normal
125125
with parameters $(\mu_1 + \mu_2, \sigma_1^2 + \sigma_2^2)$.
126126

127-
**Note:** While the product of two log normal distributions is log normal, the **sum** of two log normal distributions is **not** log normal.
127+
```{note}
128+
While the product of two log normal distributions is log normal, the **sum** of two log normal distributions is **not** log normal.
129+
```
128130

129131
This observation sets the stage for challenge that confronts us in this lecture, namely, to approximate probability distributions of **sums** of independent log normal random variables.
130132

@@ -273,9 +275,10 @@ def pdf_seq(μ,σ,I,m):
273275
<!-- #region -->
274276
Now we shall set a grid length $I$ and a grid increment size $m =1$ for our discretizations.
275277

276-
**Note**: We set $I$ equal to a power of two because we want to be free to use a Fast Fourier Transform
278+
```{note}
279+
We set $I$ equal to a power of two because we want to be free to use a Fast Fourier Transform
277280
to compute a convolution of two sequences (discrete distributions).
278-
281+
```
279282

280283
We recommend experimenting with different values of the power $p$ of 2.
281284

@@ -300,7 +303,7 @@ NT = x.size
300303
301304
plt.figure(figsize = (8,8))
302305
plt.subplot(2,1,1)
303-
plt.plot(x[:np.int(NT)],p1[:np.int(NT)],label = '')
306+
plt.plot(x[:int(NT)],p1[:int(NT)],label = '')
304307
plt.xlim(0,2500)
305308
count, bins, ignored = plt.hist(s1, 1000, density=True, align='mid')
306309
@@ -413,7 +416,7 @@ NT= np.size(x)
413416
414417
plt.figure(figsize = (8,8))
415418
plt.subplot(2,1,1)
416-
plt.plot(x[:np.int(NT)],c1f[:np.int(NT)]/m,label = '')
419+
plt.plot(x[:int(NT)],c1f[:int(NT)]/m,label = '')
417420
plt.xlim(0,5000)
418421
419422
count, bins, ignored = plt.hist(ssum2, 1000, density=True, align='mid')
@@ -426,7 +429,7 @@ plt.show()
426429
NT= np.size(x)
427430
plt.figure(figsize = (8,8))
428431
plt.subplot(2,1,1)
429-
plt.plot(x[:np.int(NT)],c2f[:np.int(NT)]/m,label = '')
432+
plt.plot(x[:int(NT)],c2f[:int(NT)]/m,label = '')
430433
plt.xlim(0,5000)
431434
432435
count, bins, ignored = plt.hist(ssum3, 1000, density=True, align='mid')
@@ -577,9 +580,10 @@ mu6, sigma6 = 1.444, 1.4632
577580
mu7, sigma7 = -.040, 1.4632
578581
579582
```
580-
581-
**Note:** Because the failure rates are all very small, log normal distributions with the
583+
```{note}
584+
Because the failure rates are all very small, log normal distributions with the
582585
above parameter values actually describe $P(A_i)$ times $10^{-09}$.
586+
```
583587
584588
So the probabilities that we'll put on the $x$ axis of the probability mass function and associated cumulative distribution function should be multiplied by $10^{-09}$
585589
@@ -650,9 +654,9 @@ print("time for 13 convolutions = ", tdiff13)
650654
651655
```{code-cell} python3
652656
d13 = np.cumsum(c13)
653-
Nx=np.int(1400)
657+
Nx=int(1400)
654658
plt.figure()
655-
plt.plot(x[0:np.int(Nx/m)],d13[0:np.int(Nx/m)]) # show Yad this -- I multiplied by m -- step size
659+
plt.plot(x[0:int(Nx/m)],d13[0:int(Nx/m)]) # show Yad this -- I multiplied by m -- step size
656660
plt.hlines(0.5,min(x),Nx,linestyles='dotted',colors = {'black'})
657661
plt.hlines(0.9,min(x),Nx,linestyles='dotted',colors = {'black'})
658662
plt.hlines(0.95,min(x),Nx,linestyles='dotted',colors = {'black'})

lectures/house_auction.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ We describe two distinct mechanisms
4343

4444
* A special case of a Groves-Clarke {cite}`Groves_73`, {cite}`Clarke_71` mechanism with a benevolent social planner
4545

46+
```{note}
47+
In 1994, the multiple rounds, ascending bid auction was actually used by Stanford University to sell leases to 9 lots on the Stanford campus to eligible faculty members.
48+
```
4649

47-
**Note:** In 1994, the multiple rounds, ascending bid auction was actually used by Stanford University to sell leases to 9 lots on the Stanford campus to eligible faculty members.
48-
4950
We begin with overviews of the two mechanisms.
5051

5152
## Ascending Bids Auction for Multiple Goods

lectures/lake_model.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,9 @@ In this exercise, your task is to arrange the `LakeModel` class by using descrip
922922
```
923923

924924

925-
```{exercise}
925+
```{exercise-start}
926926
:label: lm_ex2
927+
```
927928

928929
Consider an economy with an initial stock of workers $N_0 = 100$ at the
929930
steady state level of employment in the baseline parameterization
@@ -945,7 +946,11 @@ How long does the economy take to converge to its new steady state?
945946

946947
What is the new steady state level of employment?
947948

948-
Note: it may be easier to use the class created in exercise 1 to help with changing variables.
949+
```{note}
950+
It may be easier to use the class created in exercise 1 to help with changing variables.
951+
```
952+
953+
```{exercise-end}
949954
```
950955

951956

lectures/lln_clt.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,10 +771,12 @@ where
771771
* each $U_i$ is an IID draw from the uniform distribution on $[-2, 2]$.
772772
* $U_i$ and $W_i$ are independent of each other.
773773

774-
Hints:
774+
```{hint}
775+
:class: dropdown
775776
776777
1. `scipy.linalg.sqrtm(A)` computes the square root of `A`. You still need to invert it.
777778
1. You should be able to work out $\Sigma$ from the preceding information.
779+
```
778780

779781
```{exercise-end}
780782
```

lectures/mccall_model_with_separation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ If he rejects, then he receives unemployment compensation $c$.
124124

125125
The process then repeats.
126126

127-
(Note: we do not allow for job search while employed---this topic is taken up in a {doc}`later lecture <jv>`.)
127+
```{note}
128+
We do not allow for job search while employed---this topic is taken up in a {doc}`later lecture <jv>`.
129+
```
128130

129131
## Solving the Model
130132

lectures/pandas_panel.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Selecting one year and stacking the two lower levels of the
153153
`MultiIndex` creates a cross-section of our panel data
154154

155155
```{code-cell} python3
156-
realwage['2015'].stack(level=(1, 2)).transpose().head()
156+
realwage.loc['2015'].stack(level=(1, 2)).transpose().head()
157157
```
158158

159159
For the rest of lecture, we will work with a dataframe of the hourly
@@ -398,13 +398,13 @@ We can also specify a level of the `MultiIndex` (in the column axis)
398398
to aggregate over
399399

400400
```{code-cell} python3
401-
merged.mean(level='Continent', axis=1).head()
401+
merged.groupby(level='Continent', axis=1).mean().head()
402402
```
403403

404404
We can plot the average minimum wages in each continent as a time series
405405

406406
```{code-cell} python3
407-
merged.mean(level='Continent', axis=1).plot()
407+
merged.groupby(level='Continent', axis=1).mean().plot()
408408
plt.title('Average real minimum wage')
409409
plt.ylabel('2015 USD')
410410
plt.xlabel('Year')
@@ -415,7 +415,7 @@ We will drop Australia as a continent for plotting purposes
415415

416416
```{code-cell} python3
417417
merged = merged.drop('Australia', level='Continent', axis=1)
418-
merged.mean(level='Continent', axis=1).plot()
418+
merged.groupby(level='Continent', axis=1).mean().plot()
419419
plt.title('Average real minimum wage')
420420
plt.ylabel('2015 USD')
421421
plt.xlabel('Year')
@@ -473,7 +473,7 @@ import seaborn as sns
473473
continents = grouped.groups.keys()
474474
475475
for continent in continents:
476-
sns.kdeplot(grouped.get_group(continent)['2015'].unstack(), label=continent, shade=True)
476+
sns.kdeplot(grouped.get_group(continent).loc['2015'].unstack(), label=continent, shade=True)
477477
478478
plt.title('Real minimum wages in 2015')
479479
plt.xlabel('US dollars')
@@ -517,16 +517,23 @@ Write a program that quickly returns all values in the `MultiIndex`.
517517
```
518518

519519

520-
```{exercise}
520+
```{exercise-start}
521521
:label: pp_ex2
522+
```
522523

523524
Filter the above dataframe to only include employment as a percentage of
524525
'active population'.
525526

526527
Create a grouped boxplot using `seaborn` of employment rates in 2015
527528
by age group and sex.
528529

529-
**Hint:** `GEO` includes both areas and countries.
530+
```{hint}
531+
:class: dropdown
532+
533+
`GEO` includes both areas and countries.
534+
```
535+
536+
```{exercise-end}
530537
```
531538

532539
## Solutions
@@ -603,7 +610,7 @@ employ_f = employ_f.drop('Total', level='SEX', axis=1)
603610
```
604611

605612
```{code-cell} python3
606-
box = employ_f['2015'].unstack().reset_index()
613+
box = employ_f.loc['2015'].unstack().reset_index()
607614
sns.boxplot(x="AGE", y=0, hue="SEX", data=box, palette=("husl"), showfliers=False)
608615
plt.xlabel('')
609616
plt.xticks(rotation=35)

0 commit comments

Comments
 (0)