Convert wealth_dynamics lecture from numba to JAX#632
Closed
Conversation
Co-authored-by: mmcky <8263752+mmcky@users.noreply.github.com>
Co-authored-by: mmcky <8263752+mmcky@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [wealth_dynamics] Update lecture to use JAX instead of numba
Convert wealth_dynamics lecture from numba to JAX
Sep 26, 2025
|
📖 Netlify Preview Ready! Preview URL: https://pr-632--sunny-cactus-210e3e.netlify.app (85edd95) 📚 Changed Lecture Pages: wealth_dynamics |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR converts the
wealth_dynamicslecture from numba to JAX, following the QuantEcon JAX style guidelines and addressing issue #[issue_number].Overview
The wealth dynamics lecture previously used numba's
jitclassand parallel processing for performance. This conversion modernizes the implementation to use JAX's functional programming paradigm, vectorization, and JIT compilation.Key Changes
Architecture Conversion
jitclassto JAXNamedTuplefor immutability and better type safetyz_mean,y_mean, etc.create_wealth_dynamics()to handle stability condition checking since NamedTuple doesn't support__post_init__Function Modernization
lax.scanfor efficient time series generationprangeparallelization with JAXvmapvectorizationRandom Number Generation
Performance & Compatibility
@jax.jitwithstatic_argnamesfor parameters that need to be compile-time constantsjax.config.update("jax_enable_x64", True)for financial calculationsqe.gini_coefficient()andqe.lorenz_curve()Example Usage
The API remains largely the same, with the main difference being explicit random key management:
Benefits
Testing
All functionality has been comprehensively tested:
Documentation
The conversion maintains full functional compatibility while providing the benefits of JAX's modern computational framework.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.