Skip to content

Commit 516568e

Browse files
authored
Remove searchsorted from mccall with sep (#696)
* misc * misc
1 parent 670d7c0 commit 516568e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lectures/mccall_model_with_separation.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,17 +467,18 @@ Here's a function `compute_reservation_wage` that takes an instance of `Model`
467467
and returns the associated reservation wage.
468468

469469
```{code-cell} ipython3
470-
@jax.jit
471470
def compute_reservation_wage(model):
472471
"""
473472
Computes the reservation wage of an instance of the McCall model
474-
by finding the smallest w such that v_e(w) >= h. If no such w exists, then
475-
w_bar is set to np.inf.
476-
"""
473+
by finding the smallest w such that v_e(w) >= h.
477474
475+
"""
476+
# Find the first i such that v_e(w_i) >= h and return w[i]
477+
# If no such w exists, then w_bar is set to np.inf
478478
v_e, h = solve_model(model)
479-
i = jnp.searchsorted(v_e, h, side='left')
480-
w_bar = jnp.where(i >= len(model.w), jnp.inf, model.w[i])
479+
accept = v_e >= h
480+
i = jnp.argmax(accept) # take first accept index
481+
w_bar = jnp.where(jnp.any(accept), model.w[i], jnp.inf)
481482
return w_bar
482483
```
483484

0 commit comments

Comments
 (0)