Skip to content

Commit 00d48d5

Browse files
committed
edit_graphviz
1 parent 60efb43 commit 00d48d5

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed
-56 KB
Binary file not shown.

lectures/lake_model.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,29 @@ The "flows" between the two lakes are as follows:
4040
3. employed workers separate from their jobs at rate $\alpha$.
4141
4. unemployed workers find jobs at rate $\lambda$.
4242

43-
```{figure} /_static/lecture_specific/lake_model/transition.png
44-
---
45-
scale: 60%
46-
43+
The below graph illustrates the lake model.
44+
45+
```{code-cell}ipython3
46+
from graphviz import Digraph
47+
# Create Digraph object
48+
G = Digraph()
49+
G.attr(rankdir='LR')
50+
51+
# Add nodes
52+
G.attr('node', shape='circle')
53+
G.node('1', 'New netrants', color='blue')
54+
G.node('2', 'Unemployed')
55+
G.node('3', 'Employed')
56+
57+
# Add edges
58+
G.edge('1', '2', label='b')
59+
G.edge('2', '3', label='λ(1-d)')
60+
G.edge('3', '2', label='α(1-d)')
61+
G.edge('2', '2', label='(1-λ)(1-d)')
62+
G.edge('3', '3', label='(1-α)(1-d)')
63+
64+
# Show graphviz
65+
G
4766
```
4867

4968
Let $e_t$ and $u_t$ be the number of employed and unemployed workers at time $t$ respectively.
@@ -323,11 +342,11 @@ def plot_time_paths(lm, x0=None, T=1000, ax=None):
323342
plt.show()
324343
```
325344

326-
````{code-cell} ipython3
345+
```{code-cell} ipython3
327346
lm = LakeModel(α=0.01, λ=0.1, d=0.02, b=0.025)
328347
x0 = ((5.0, 0.1), (0.1, 4.0), (2.0, 1.0))
329348
plot_time_paths(lm, x0=x0)
330-
```{code-cell}
349+
```
331350

332351
If $\bar{x}$ is an eigenvector corresponding to the eigenvalue $r(A)$ then all the vectors in the set
333352
$D := \{ x \in \mathbb{R}^2 : x = \alpha \bar{x} \; \text{for some} \; \alpha >0 \}$ are also eigenvectors corresponding
@@ -352,7 +371,7 @@ This is visualised below.
352371
```{code-cell} ipython3
353372
lm = LakeModel(α=0.01, λ=0.1, d=0.025, b=0.02)
354373
plot_time_paths(lm, x0=x0)
355-
````
374+
```
356375

357376
Thus, while the sequence of iterates still move towards the dominant eigenvector $\bar{x}$ however in this case
358377
they converge to the origin.
@@ -471,7 +490,7 @@ Assume that $\alpha$ increases to $0.04$.
471490

472491
The below graph illustrates that the line $D$ shifts downward, which indicates that the fraction of unemployment rises as the separation rate increases.
473492

474-
````{code-cell} ipython3
493+
```{code-cell} ipython3
475494
fig, ax = plt.subplots(figsize=(10, 8))
476495
477496
lm = LakeModel(α=0.01, λ=0.1, d=0.02, b=0.025)
@@ -485,7 +504,4 @@ ax.plot([0, s * lm.ū], [0, s * lm.ē], "r--", lw=1, label='set $D$, α=0.04')
485504
486505
ax.legend(loc='best')
487506
plt.show()
488-
```{code-cell}
489-
490-
491-
````
507+
```

0 commit comments

Comments
 (0)