GitHub

@@ -467,17 +467,18 @@ Here's a function `compute_reservation_wage` that takes an instance of `Model`

467467

and returns the associated reservation wage.

468468469469

```{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.

477474475+

"""

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

Read the original on github.com ↗