Refine lake_model.md: Remove redundant decorators and improve organization#664
Refine lake_model.md: Remove redundant decorators and improve organization#664
Conversation
…ation
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>
|
📖 Netlify Preview Ready! Preview URL: https://pr-664--sunny-cactus-210e3e.netlify.app (27bb29b) 📚 Changed Lecture Pages: lake_model |
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>
|
📖 Netlify Preview Ready! Preview URL: https://pr-664--sunny-cactus-210e3e.netlify.app (8a84067) 📚 Changed Lecture Pages: lake_model |
Additional Refactoring: Improved Model Structure and NotationI've made additional improvements to Key Changes:
All code has been tested and verified to work correctly. ✅ |
|
📖 Netlify Preview Ready! Preview URL: https://pr-664--sunny-cactus-210e3e.netlify.app (8cce1a7) 📚 Changed Lecture Pages: lake_model |
Summary
This PR refines the Lake Model lecture with several improvements to code quality, performance, and pedagogical flow:
Code improvements:
@jax.jitdecorators from helper functions (compute_matrices,stock_update,rate_update,markov_update)Content organization:
vmapfunctionality, removing less pedagogically interesting parameter comparisonsTest plan
🤖 Generated with Claude Code