Skip to content

Commit b617df5

Browse files
mnshkwshlffmmckyoyamad
authored
[LakeModel] Simplify computation of the steady state (#355)
* [LakeModel] Simplify computation of the steady state * fix * rephrase * Update lectures/lake_model.md Co-authored-by: Daisuke Oyama <[email protected]> * Update lectures/lake_model.md Co-authored-by: Daisuke Oyama <[email protected]> * Update lectures/lake_model.md * Revert "Update lectures/lake_model.md" This reverts commit 2473f00. * Revert "Update lectures/lake_model.md" This reverts commit d7d8f3a. * incorporate text changes from @jstac * clarification Co-authored-by: mmcky <[email protected]> * Update lectures/lake_model.md --------- Co-authored-by: shlff <[email protected]> Co-authored-by: mmcky <[email protected]> Co-authored-by: Daisuke Oyama <[email protected]> Co-authored-by: mmcky <[email protected]>
1 parent e585437 commit b617df5

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lectures/lake_model.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ This class will
218218
1. store the primitives $\alpha, \lambda, b, d$
219219
1. compute and store the implied objects $g, A, \hat A$
220220
1. provide methods to simulate dynamics of the stocks and rates
221-
1. provide a method to compute the steady state of the rate
221+
2. provide a method to compute the steady state vector $\bar x$ of employment and unemployment rates using {ref}`a technique <dynamics_workers>` we previously introduced for computing stationary distributions of Markov chains
222222

223223
Please be careful because the implied objects $g, A, \hat A$ will not change
224224
if you only change the primitives.
@@ -265,12 +265,8 @@ class LakeModel:
265265
--------
266266
xbar : steady state vector of employment and unemployment rates
267267
"""
268-
x = np.full(2, 0.5)
269-
error = tol + 1
270-
while error > tol:
271-
new_x = self.A_hat @ x
272-
error = np.max(np.abs(new_x - x))
273-
x = new_x
268+
x = np.array([self.A_hat[0, 1], self.A_hat[1, 0]])
269+
x /= x.sum()
274270
return x
275271
276272
def simulate_stock_path(self, X0, T):
@@ -415,6 +411,7 @@ plt.tight_layout()
415411
plt.show()
416412
```
417413

414+
(dynamics_workers)=
418415
## Dynamics of an Individual Worker
419416

420417
An individual worker's employment dynamics are governed by a {doc}`finite state Markov process <finite_markov>`.
@@ -1016,12 +1013,8 @@ class LakeModelModified:
10161013
--------
10171014
xbar : steady state vector of employment and unemployment rates
10181015
"""
1019-
x = np.full(2, 0.5)
1020-
error = tol + 1
1021-
while error > tol:
1022-
new_x = self.A_hat @ x
1023-
error = np.max(np.abs(new_x - x))
1024-
x = new_x
1016+
x = np.array([self.A_hat[0, 1], self.A_hat[1, 0]])
1017+
x /= x.sum()
10251018
return x
10261019
10271020
def simulate_stock_path(self, X0, T):

0 commit comments

Comments
 (0)