Skip to content

Commit 7d356f6

Browse files
jstacclaude
andcommitted
Simplify function names and documentation in IFP transient shocks lecture
Rename compute_expectation_k to expected_mu for clarity and brevity. Streamline inline comments to improve code readability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent afdf896 commit 7d356f6

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

lectures/ifp_egm_transient_shocks.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -456,17 +456,13 @@ def K(
456456
return jnp.exp(a_y * η + z * b_y)
457457
458458
def compute_c(i, j):
459-
" Function to compute consumption for one (i, j) pair where i >= 1. "
459+
" Compute c_ij when i >= 1 (interior choice). "
460460
461-
def compute_expectation_k(k):
462-
"""
463-
For each k, approximate the integral
464-
465-
∫ u'(σ(R s_i + y(z_k, η'), z_k)) φ(η') dη'
466-
"""
461+
def expected_mu(k):
462+
" Approximate ∫ u'(σ(R s_i + y(z_k, η'), z_k)) φ(η') dη' "
467463
468464
def compute_mu_at_eta(η):
469-
" For each η draw, compute u'(σ(R * s_i + y(z_k, η), z_k)) "
465+
" Compute u'(σ(R * s_i + y(z_k, η), z_k)) "
470466
next_a = R * s[i] + y(z_grid[k], η)
471467
# Interpolate to get σ(R * s_i + y(z_k, η), z_k)
472468
next_c = jnp.interp(next_a, a_in[:, k], c_in[:, k])
@@ -479,10 +475,9 @@ def K(
479475
return jnp.mean(all_draws)
480476
481477
# Compute expectation: Σ_k [∫ u'(σ(...)) φ(η) dη] * Π[j, k]
482-
expectations = jax.vmap(compute_expectation_k)(jnp.arange(n_z))
478+
expectations = jax.vmap(expected_mu)(jnp.arange(n_z))
483479
expectation = jnp.sum(expectations * Π[j, :])
484-
485-
# Invert to get consumption c_{ij} at (s_i, z_j)
480+
# Invert to get consumption c_ij at (s_i, z_j)
486481
return u_prime_inv(β * R * expectation)
487482
488483
# Set up index grids for vmap computation of all c_{ij}

0 commit comments

Comments
 (0)