-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce54d93
commit 771b8bc
Showing
58 changed files
with
1,723 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
xmin = -0.5 | ||
xmax = 2.0 | ||
|
||
xgrid = np.linspace(xmin, xmax, 1000) | ||
|
||
a1, b1 = 0.15, 0.5 # first T_σ | ||
a2, b2 = 0.5, 0.4 # second T_σ | ||
a3, b3 = 0.75, 0.2 # third T_σ | ||
|
||
v1 = b1/(1-a1) | ||
v2 = b2/(1-a2) | ||
v3 = b3/(1-a3) | ||
|
||
T1 = a1 * xgrid + b1 | ||
T2 = a2 * xgrid + b2 | ||
T3 = a3 * xgrid + b3 | ||
T = np.maximum.reduce([T1, T2, T3]) | ||
|
||
fig, ax = plt.subplots(figsize=(6, 5)) | ||
for spine in ["left", "bottom"]: | ||
ax.spines[spine].set_position("zero") | ||
|
||
for spine in ["right", "top"]: | ||
ax.spines[spine].set_color("none") | ||
|
||
ax.plot(xgrid, T1, "k-", lw=1) | ||
ax.plot(xgrid, T2, "k-", lw=1) | ||
ax.plot(xgrid, T3, "k-", lw=1) | ||
|
||
ax.plot(xgrid, T, lw=6, alpha=0.3, color="blue", | ||
label=r"$T = \bigvee_{\sigma \in \Sigma} T_\sigma$") | ||
|
||
|
||
ax.text(2.1, 0.6, r"$T_{\sigma'}$") | ||
ax.text(2.1, 1.4, r"$T_{\sigma''}$") | ||
ax.text(2.1, 1.9, r"$T_{\sigma'''}$") | ||
|
||
ax.legend(frameon=False, loc="upper center") | ||
|
||
|
||
ax.set_xlim(xmin, xmax+0.5) | ||
ax.set_ylim(-0.2, 2.5) | ||
ax.text(2.4, -0.15, r"$v$") | ||
|
||
ax.set_xticks([]) | ||
ax.set_yticks([]) | ||
|
||
plt.show() | ||
|
||
file_name = "../figures_py/bellman_envelope.png" | ||
fig.savefig(file_name) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from scipy.stats import binom | ||
|
||
|
||
n, m, p = 10, 18, 0.5 | ||
|
||
phi = binom(n, p) | ||
psi = binom(m, p) | ||
|
||
x = np.arange(0, m+1) | ||
|
||
fig, ax = plt.subplots(figsize=(9, 5.2)) | ||
lb = r"$\phi = B({}, {})$".format(n, p) | ||
ax.plot(x, np.concatenate((phi.pmf(np.arange(0, n+1)), | ||
np.zeros(m-n))), "-o", alpha=0.6, label=lb) | ||
lb = r"$\psi = B({}, {})$".format(m, p) | ||
ax.plot(x, psi.pmf(x), "-o", alpha=0.6, label=lb) | ||
|
||
ax.legend(fontsize=16, frameon=False) | ||
|
||
plt.show() | ||
|
||
file_name = "../figures_py/binom_stoch_dom.png" | ||
fig.savefig(file_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
x0 = 0.25 | ||
xmin, xmax = 0, 3 | ||
fs = 18 | ||
|
||
x_grid = np.linspace(xmin, xmax, 1200) | ||
|
||
def g(x): | ||
return 1 + 0.5 * x**0.5 | ||
|
||
xstar = 1.64 | ||
|
||
fig, ax = plt.subplots(figsize=(10, 5.5)) | ||
|
||
# Plot the functions | ||
lb = r"$g$" | ||
ax.plot(x_grid, g(x_grid), lw=2, alpha=0.6, label=lb) | ||
ax.plot(x_grid, x_grid, "k--", lw=1, alpha=0.7, label=r"$45$") | ||
|
||
# Show and annotate the fixed point | ||
fps = (xstar,) | ||
ax.plot(fps, fps, "go", ms=10, alpha=0.6) | ||
ax.set_xlabel(r"$x$", fontsize=fs) | ||
ax.annotate(r"$x^*$", | ||
xy=(xstar, xstar), | ||
xycoords="data", | ||
xytext=(-20, 20), | ||
textcoords="offset points", | ||
fontsize=fs) | ||
|
||
ax.legend(loc="upper left", frameon=False, fontsize=fs) | ||
ax.set_xticks((0, 1, 2, 3)) | ||
ax.set_yticks((0, 1, 2, 3)) | ||
ax.set_ylim(0, 3) | ||
ax.set_xlim(0, 3) | ||
|
||
plt.show() | ||
|
||
file_name = "../figures_py/concave_map_fp.png" | ||
fig.savefig(file_name) |
Oops, something went wrong.
771b8bc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Deployed on https://6704e7bfecb9f1ffa12c7431--resonant-pie-f0089d.netlify.app