QuantEcon ยท GitHub

Commit 1c98e34

jstacclaude

and

authored

Refine lake_model.md: Remove redundant decorators and improve organization (#664)

* Refine lake_model.md: Remove redundant decorators and improve organization This commit improves the Lake Model lecture with several refinements: **Code improvements:** - Remove redundant `@jax.jit` decorators from `compute_matrices`, `stock_update`, `rate_update`, and `markov_update` (these functions are only called from within jitted functions, so the decorators are unnecessary and can inhibit compiler optimization) - Refactor aggregate dynamics plot to use a for loop instead of repetitive code - Remove hardcoded colors ('r') from plots to use matplotlib's default color cycle **Content organization:** - Move rate definitions ($e_t$, $u_t$) to "Laws of motion for rates" section where they logically belong - Relocate Exercise 1 to appear immediately before "Dynamics of an individual worker" section for better flow - Simplify Exercise 1 to focus on the pedagogically interesting `vmap` usage, removing less interesting parameter comparison parts These changes improve code clarity, performance, and pedagogical flow without changing functionality. ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Refactor lake_model.md: Improve model structure and notation Major improvements: - Added create_lake_model() function to generate model instances with precomputed matrices A, R, and g - Replaced A_hat notation with R throughout (code and LaTeX) for cleaner notation - Updated LakeModel NamedTuple to store computed matrices A and R - Modified all functions to unpack model using tuple unpacking for efficiency - Added type hints to stock_update(), rate_update(), and create_lake_model() - Simplified generate_path() function by removing unused time parameter - Updated rate_steady_state() to use Perron-Frobenius theorem (argmax instead of searching for eigenvalue near 1) - Converted all LakeModel() instantiations to use create_lake_model() - Updated markov simulation to use dedicated simulate_markov() function Benefits: - Matrices computed once at model creation instead of repeatedly - Cleaner mathematical notation using R instead of \hat{A} - More efficient code with direct tuple unpacking - Better type safety with added annotations - More mathematically rigorous using Perron-Frobenius theorem ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * misc --------- Co-authored-by: Claude <noreply@anthropic.com>

1 file changed

Lines changed: 188 additions & 172 deletions

Read the original on github.com โ†—