Commit e5c45f4
Refactor cake_eating_numerical: Convert from OOP to functional style
Modernized the cake eating numerical methods lecture by replacing class-based
implementation with a functional programming approach using NamedTuple.
Key changes:
- Replaced `class CakeEating` with `Model = namedtuple('Model', ...)`
- Created `create_cake_eating_model()` helper function for building instances
- Converted class methods to standalone functions:
- `u(c, γ)` for utility function
- `u_prime(c, γ)` for utility derivative
- `state_action_value(c, x, v_array, model)` for Bellman RHS
- Updated Bellman operator `T(v, model)` to use functional style
- Modified policy function `σ(model, v)` to accept model parameter
- Refactored exercise solution from inheritance-based `class OptimalGrowth(CakeEating)`
to `class ExtendedModel(NamedTuple)` with standalone functions
- Updated all code examples throughout to use `model` parameter pattern
- Generated and tested Python version using jupytext
This aligns with the modern functional style used in cake_eating.md and
reduces reliance on OOP patterns.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 11e5850 commit e5c45f4
File tree
2 files changed
+814
-240
lines changed- lectures
2 files changed
+814
-240
lines changed
0 commit comments