Skip to content

Commit b3a2f89

Browse files
committed
update cases with r
1 parent d66a492 commit b3a2f89

File tree

10 files changed

+36
-36
lines changed

10 files changed

+36
-36
lines changed

lectures/ak2.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -760,26 +760,26 @@ fig, axs = plt.subplots(3, 3, figsize=(14, 10))
760760
# quantities
761761
for i, name in enumerate(['K', 'Y', 'Cy', 'Co']):
762762
ax = axs[i//3, i%3]
763-
ax.plot(range(T+1), quant_seq1[:T+1, i], label=name+', 1/3')
764-
ax.plot(range(T+1), quant_seq2[:T+1, i], label=name+', 0.2')
763+
ax.plot(range(T+1), quant_seq1[:T+1, i], label=f'{name}, 1/3')
764+
ax.plot(range(T+1), quant_seq2[:T+1, i], label=f'{name}, 0.2')
765765
ax.hlines(init_ss[i], 0, T+1, color='r', linestyle='--')
766766
ax.legend()
767767
ax.set_xlabel('t')
768768
769769
# prices
770770
for i, name in enumerate(['W', 'r']):
771771
ax = axs[(i+4)//3, (i+4)%3]
772-
ax.plot(range(T+1), price_seq1[:T+1, i], label=name+', 1/3')
773-
ax.plot(range(T+1), price_seq2[:T+1, i], label=name+', 0.2')
772+
ax.plot(range(T+1), price_seq1[:T+1, i], label=f'{name}, 1/3')
773+
ax.plot(range(T+1), price_seq2[:T+1, i], label=f'{name}, 0.2')
774774
ax.hlines(init_ss[i+4], 0, T+1, color='r', linestyle='--')
775775
ax.legend()
776776
ax.set_xlabel('t')
777777
778778
# policies
779779
for i, name in enumerate(['τ', 'D', 'G']):
780780
ax = axs[(i+6)//3, (i+6)%3]
781-
ax.plot(range(T+1), policy_seq1[:T+1, i], label=name+', 1/3')
782-
ax.plot(range(T+1), policy_seq2[:T+1, i], label=name+', 0.2')
781+
ax.plot(range(T+1), policy_seq1[:T+1, i], label=f'{name}, 1/3')
782+
ax.plot(range(T+1), policy_seq2[:T+1, i], label=f'{name}, 0.2')
783783
ax.hlines(init_ss[i+6], 0, T+1, color='r', linestyle='--')
784784
ax.legend()
785785
ax.set_xlabel('t')
@@ -1179,26 +1179,26 @@ fig, axs = plt.subplots(3, 3, figsize=(14, 10))
11791179
# quantities
11801180
for i, name in enumerate(['K', 'Y', 'Cy', 'Co']):
11811181
ax = axs[i//3, i%3]
1182-
ax.plot(range(T+1), quant_seq3[:T+1, i], label=name+', $\delta$s=0')
1183-
ax.plot(range(T+1), quant_seq4[:T+1, i], label=name+', $\delta$s=0.005')
1182+
ax.plot(range(T+1), quant_seq3[:T+1, i], label=rf'{name}, $\delta$s=0')
1183+
ax.plot(range(T+1), quant_seq4[:T+1, i], label=rf'{name}, $\delta$s=0.005')
11841184
ax.hlines(init_ss[i], 0, T+1, color='r', linestyle='--')
11851185
ax.legend()
11861186
ax.set_xlabel('t')
11871187
11881188
# prices
11891189
for i, name in enumerate(['W', 'r']):
11901190
ax = axs[(i+4)//3, (i+4)%3]
1191-
ax.plot(range(T+1), price_seq3[:T+1, i], label=name+', $\delta$s=0')
1192-
ax.plot(range(T+1), price_seq4[:T+1, i], label=name+', $\delta$s=0.005')
1191+
ax.plot(range(T+1), price_seq3[:T+1, i], label=rf'{name}, $\delta$s=0')
1192+
ax.plot(range(T+1), price_seq4[:T+1, i], label=rf'{name}, $\delta$s=0.005')
11931193
ax.hlines(init_ss[i+4], 0, T+1, color='r', linestyle='--')
11941194
ax.legend()
11951195
ax.set_xlabel('t')
11961196
11971197
# policies
11981198
for i, name in enumerate(['τ', 'D', 'G']):
11991199
ax = axs[(i+6)//3, (i+6)%3]
1200-
ax.plot(range(T+1), policy_seq3[:T+1, i], label=name+', $\delta$s=0')
1201-
ax.plot(range(T+1), policy_seq4[:T+1, i], label=name+', $\delta$s=0.005')
1200+
ax.plot(range(T+1), policy_seq3[:T+1, i], label=rf'{name}, $\delta$s=0')
1201+
ax.plot(range(T+1), policy_seq4[:T+1, i], label=rf'{name}, $\delta$s=0.005')
12021202
ax.hlines(init_ss[i+6], 0, T+1, color='r', linestyle='--')
12031203
ax.legend()
12041204
ax.set_xlabel('t')
@@ -1244,26 +1244,26 @@ fig, axs = plt.subplots(3, 3, figsize=(14, 10))
12441244
# quantities
12451245
for i, name in enumerate(['K', 'Y', 'Cy', 'Co']):
12461246
ax = axs[i//3, i%3]
1247-
ax.plot(range(T+1), quant_seq3[:T+1, i], label=name+', tax cut')
1248-
ax.plot(range(T+1), quant_seq5[:T+1, i], label=name+', transfer')
1247+
ax.plot(range(T+1), quant_seq3[:T+1, i], label=f'{name}, tax cut')
1248+
ax.plot(range(T+1), quant_seq5[:T+1, i], label=f'{name}, transfer')
12491249
ax.hlines(init_ss[i], 0, T+1, color='r', linestyle='--')
12501250
ax.legend()
12511251
ax.set_xlabel('t')
12521252
12531253
# prices
12541254
for i, name in enumerate(['W', 'r']):
12551255
ax = axs[(i+4)//3, (i+4)%3]
1256-
ax.plot(range(T+1), price_seq3[:T+1, i], label=name+', tax cut')
1257-
ax.plot(range(T+1), price_seq5[:T+1, i], label=name+', transfer')
1256+
ax.plot(range(T+1), price_seq3[:T+1, i], label=f'{name}, tax cut')
1257+
ax.plot(range(T+1), price_seq5[:T+1, i], label=f'{name}, transfer')
12581258
ax.hlines(init_ss[i+4], 0, T+1, color='r', linestyle='--')
12591259
ax.legend()
12601260
ax.set_xlabel('t')
12611261
12621262
# policies
12631263
for i, name in enumerate(['τ', 'D', 'G']):
12641264
ax = axs[(i+6)//3, (i+6)%3]
1265-
ax.plot(range(T+1), policy_seq3[:T+1, i], label=name+', tax cut')
1266-
ax.plot(range(T+1), policy_seq5[:T+1, i], label=name+', transfer')
1265+
ax.plot(range(T+1), policy_seq3[:T+1, i], label=f'{name}, tax cut')
1266+
ax.plot(range(T+1), policy_seq5[:T+1, i], label=f'{name}, transfer')
12671267
ax.hlines(init_ss[i+6], 0, T+1, color='r', linestyle='--')
12681268
ax.legend()
12691269
ax.set_xlabel('t')

lectures/finite_markov.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,11 +1242,11 @@ The following code snippet provides a hint as to how you can go about this
12421242
12431243
```{code-cell} python3
12441244
import re
1245-
re.findall('\w', 'x +++ y ****** z') # \w matches alphanumerics
1245+
re.findall(r'\w', 'x +++ y ****** z') # \w matches alphanumerics
12461246
```
12471247
12481248
```{code-cell} python3
1249-
re.findall('\w', 'a ^^ b &&& $$ c')
1249+
re.findall(r'\w', 'a ^^ b &&& $$ c')
12501250
```
12511251
12521252
When you solve for the ranking, you will find that the highest ranked node is in fact `g`, while the lowest is `a`.

lectures/likelihood_bayes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ for t in range(T):
314314
fig, ax1 = plt.subplots()
315315
316316
for i in range(2):
317-
ax1.plot(range(T+1), π_seq_f[i, :], label=f"$\pi_0$={π_seq_f[i, 0]}")
317+
ax1.plot(range(T+1), π_seq_f[i, :], label=fr"$\pi_0$={π_seq_f[i, 0]}")
318318
319319
ax1.set_ylabel("$\pi_t$")
320320
ax1.set_xlabel("t")
@@ -348,7 +348,7 @@ for t in range(T):
348348
fig, ax1 = plt.subplots()
349349
350350
for i in range(2):
351-
ax1.plot(range(T+1), π_seq_g[i, :], label=f"$\pi_0$={π_seq_g[i, 0]}")
351+
ax1.plot(range(T+1), π_seq_g[i, :], label=fr"$\pi_0$={π_seq_g[i, 0]}")
352352
353353
ax1.set_ylabel("$\pi_t$")
354354
ax1.set_xlabel("t")

lectures/linear_models.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ y = y.flatten()
738738
ygrid = np.linspace(ymin, ymax, 150)
739739
740740
ax.hist(y, bins=50, density=True, alpha=0.4)
741-
ax.plot(ygrid, f_y.pdf(ygrid), 'k-', lw=2, alpha=0.8, label=r'true density')
741+
ax.plot(ygrid, f_y.pdf(ygrid), 'k-', lw=2, alpha=0.8, label='true density')
742742
ax.set_xlim(ymin, ymax)
743743
ax.set_xlabel('$y_t$', fontsize=12)
744744
ax.set_ylabel('relative frequency', fontsize=12)
@@ -802,7 +802,7 @@ for t in range(T):
802802
μ_x, μ_y, Σ_x, Σ_y = next(m)
803803
population_means.append(float(μ_y))
804804
805-
ax.plot(population_means, color='g', lw=2, alpha=0.8, label='$G\mu_t$')
805+
ax.plot(population_means, color='g', lw=2, alpha=0.8, label=r'$G\mu_t$')
806806
ax.set_ylim(ymin, ymax)
807807
ax.set_xlabel('time', fontsize=12)
808808
ax.set_ylabel('$y_t$', fontsize=12)

lectures/lln_clt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ for ax in axes:
265265
axlabel = '$\\bar{X}_n$ for $X_i \sim$' + name
266266
ax.plot(list(range(n)), sample_mean, 'g-', lw=3, alpha=0.6, label=axlabel)
267267
m = distribution.mean()
268-
ax.plot(list(range(n)), [m] * n, 'k--', lw=1.5, label='$\mu$')
268+
ax.plot(list(range(n)), [m] * n, 'k--', lw=1.5, label=r'$\mu$')
269269
ax.vlines(list(range(n)), m, data, lw=0.2)
270270
ax.legend(**legend_args, fontsize=12)
271271
@@ -408,7 +408,7 @@ xmin, xmax = -3 * s, 3 * s
408408
ax.set_xlim(xmin, xmax)
409409
ax.hist(Y, bins=60, alpha=0.5, density=True)
410410
xgrid = np.linspace(xmin, xmax, 200)
411-
ax.plot(xgrid, norm.pdf(xgrid, scale=s), 'k-', lw=2, label='$N(0, \sigma^2)$')
411+
ax.plot(xgrid, norm.pdf(xgrid, scale=s), 'k-', lw=2, label=r'$N(0, \sigma^2)$')
412412
ax.legend()
413413
414414
plt.show()

lectures/mix_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def plot_π_seq(α, π1=0.2, π2=0.8, T=200):
455455
# plot
456456
fig, ax1 = plt.subplots()
457457
for i in range(2):
458-
ax1.plot(range(T+1), π_seq_mixed[i, :], label=f"$\pi_0$={π_seq_mixed[i, 0]}")
458+
ax1.plot(range(T+1), π_seq_mixed[i, :], label=fr"$\pi_0$={π_seq_mixed[i, 0]}")
459459
460460
ax1.plot(np.nan, np.nan, '--', color='b', label='Log likelihood ratio process')
461461
ax1.set_ylabel("$\pi_t$")

lectures/multivariate_normal.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ for i in range(1, n+1):
773773
μθ_hat_higher = μθ_hat_arr + 1.96 * σθ_hat_arr
774774
775775
plt.hlines(θ, 1, n+1, ls='--', label='true $θ$')
776-
plt.plot(range(1, n+1), μθ_hat_arr, color='b', label='$\hat{μ}_{θ}$')
776+
plt.plot(range(1, n+1), μθ_hat_arr, color='b', label=r'$\hat{μ}_{θ}$')
777777
plt.plot(range(1, n+1), μθ_hat_lower, color='b', ls='--')
778778
plt.plot(range(1, n+1), μθ_hat_higher, color='b', ls='--')
779779
plt.fill_between(range(1, n+1), μθ_hat_lower, μθ_hat_higher,
@@ -2277,7 +2277,7 @@ coordinate axis versus $y$ on the ordinate axis.
22772277

22782278
```{code-cell} python3
22792279
plt.scatter(range(N), Λ @ f, label='$Ey|f$')
2280-
plt.scatter(range(N), y_hat, label='$\hat{y}$')
2280+
plt.scatter(range(N), y_hat, label=r'$\hat{y}$')
22812281
plt.hlines(f[0], 0, N//2-1, ls='--', label='$f_{1}$')
22822282
plt.hlines(f[1], N//2, N-1, ls='-.', label='$f_{2}$')
22832283

lectures/util_rand_resp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,11 @@ y2 = (pow(x2, 0.5) - 0.4)**2
281281
x3 = np.arange(0.4**0.5, 1, 0.001)
282282
y3 = pow(x3**2 - 0.4, 0.5)
283283
plt.figure(figsize=(12, 10))
284-
plt.plot(x1, y1, 'r-', label='Truth Border of: $U_i(Pr(A|r_i),\phi_i)=-Pr(A|r_i)+f(\phi_i)$')
284+
plt.plot(x1, y1, 'r-', label=r'Truth Border of: $U_i(Pr(A|r_i),\phi_i)=-Pr(A|r_i)+f(\phi_i)$')
285285
plt.fill_between(x1, 0, y1, facecolor='red', alpha=0.05)
286-
plt.plot(x2, y2, 'b-', label='Truth Border of: $U_i(Pr(A|r_i),\phi_i)=-Pr(A|r_i)^{2}+f(\phi_i)$')
286+
plt.plot(x2, y2, 'b-', label=r'Truth Border of: $U_i(Pr(A|r_i),\phi_i)=-Pr(A|r_i)^{2}+f(\phi_i)$')
287287
plt.fill_between(x2, 0, y2, facecolor='blue', alpha=0.05)
288-
plt.plot(x3, y3, 'y-', label='Truth Border of: $U_i(Pr(A|r_i),\phi_i)=-\sqrt{Pr(A|r_i)}+f(\phi_i)$')
288+
plt.plot(x3, y3, 'y-', label=r'Truth Border of: $U_i(Pr(A|r_i),\phi_i)=-\sqrt{Pr(A|r_i)}+f(\phi_i)$')
289289
plt.fill_between(x3, 0, y3, facecolor='green', alpha=0.05)
290290
plt.plot(x1, x1, ':', linewidth=2)
291291
plt.xlim([0, 1])
@@ -318,7 +318,7 @@ y1 = x1 - 0.4
318318
z1 = x1
319319
z2 = 0
320320
plt.figure(figsize=(12, 10))
321-
plt.plot(x1, y1,'r-',label='Truth Border of: $U_i(Pr(A|r_i),\phi_i)=-Pr(A|r_i)+f(\phi_i)$')
321+
plt.plot(x1, y1,'r-',label=r'Truth Border of: $U_i(Pr(A|r_i),\phi_i)=-Pr(A|r_i)+f(\phi_i)$')
322322
plt.plot(x1, x1, ':', linewidth=2)
323323
plt.fill_between(x1, y1, z1, facecolor='blue', alpha=0.05, label='truth telling')
324324
plt.fill_between(x1, z2, y1, facecolor='green', alpha=0.05, label='lying')

lectures/wald_friedman.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ ax.plot(wf.π_grid, cost_L1, label='choose f1')
597597
ax.plot(wf.π_grid, cost_L0, label='choose f0')
598598
ax.plot(wf.π_grid,
599599
np.amin(np.column_stack([h_star, cost_L0, cost_L1]),axis=1),
600-
lw=15, alpha=0.1, color='b', label='$J(\pi)$')
600+
lw=15, alpha=0.1, color='b', label=r'$J(\pi)$')
601601
602602
ax.annotate(r"$\beta$", xy=(β + 0.01, 0.5), fontsize=14)
603603
ax.annotate(r"$\alpha$", xy=(α + 0.01, 0.5), fontsize=14)

lectures/wealth_dynamics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ gini_vals = []
477477
for μ_r in μ_r_vals:
478478
wdy = WealthDynamics(μ_r=μ_r)
479479
gv, (f_vals, l_vals) = generate_lorenz_and_gini(wdy)
480-
ax.plot(f_vals, l_vals, label=f'$\psi^*$ at $\mu_r = {μ_r:0.2}$')
480+
ax.plot(f_vals, l_vals, label=fr'$\psi^*$ at $\mu_r = {μ_r:0.2}$')
481481
gini_vals.append(gv)
482482
483483
ax.plot(f_vals, f_vals, label='equality')
@@ -522,7 +522,7 @@ gini_vals = []
522522
for σ_r in σ_r_vals:
523523
wdy = WealthDynamics(σ_r=σ_r)
524524
gv, (f_vals, l_vals) = generate_lorenz_and_gini(wdy)
525-
ax.plot(f_vals, l_vals, label=f'$\psi^*$ at $\sigma_r = {σ_r:0.2}$')
525+
ax.plot(f_vals, l_vals, label=fr'$\psi^*$ at $\sigma_r = {σ_r:0.2}$')
526526
gini_vals.append(gv)
527527
528528
ax.plot(f_vals, f_vals, label='equality')

0 commit comments

Comments
 (0)