https://github.com/sandyherho/kalimusada
A Python solver for the Ma-Chen financial chaotic system with sensitivity analysis and visualization.
https://github.com/sandyherho/kalimusada
chaos-theory financial-modeling nonlinear-dynamics
Last synced: 5 months ago
JSON representation
A Python solver for the Ma-Chen financial chaotic system with sensitivity analysis and visualization.
- Host: GitHub
- URL: https://github.com/sandyherho/kalimusada
- Owner: sandyherho
- License: mit
- Created: 2025-11-25T04:09:48.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-11-25T11:01:09.000Z (7 months ago)
- Last Synced: 2025-11-28T16:51:50.918Z (7 months ago)
- Topics: chaos-theory, financial-modeling, nonlinear-dynamics
- Language: Python
- Homepage: https://pypi.org/project/kalimusada/
- Size: 18.2 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `kalimusada`: a Python library for solving the Ma-Chen financial chaotic system
[](https://www.python.org/downloads/)
[](https://pypi.org/project/kalimusada/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/psf/black)
[](https://doi.org/10.5281/zenodo.17710349)
[](https://numpy.org/)
[](https://scipy.org/)
[](https://matplotlib.org/)
[](https://pandas.pydata.org/)
[](https://unidata.github.io/netcdf4-python/)
[](https://imageio.github.io/)
[](https://tqdm.github.io/)
A Python-based solver for demonstrating sensitivity to initial conditions in economic dynamics.
## Model
The Ma-Chen system describes financial dynamics through three coupled ordinary differential equations:
$$ \dot{x} = z + (y - a)x, \quad \dot{y} = 1 - by - x^2, \quad \dot{z} = -x - cz $$
where the state variables are:
| Variable | Description | Economic interpretation |
|:--------:|:------------|:------------------------|
| $x(t)$ | Interest rate | Cost of borrowing capital |
| $y(t)$ | Investment demand | Aggregate investment activity |
| $z(t)$ | Price index | General price level |
and the parameters are:
| Parameter | Description | Chaotic value |
|:---------:|:------------|:-------------:|
| $a$ | Savings rate | $0.9$ |
| $b$ | Investment cost coefficient | $0.2$ |
| $c$ | Demand elasticity | $1.2$ |
The solver simulates two trajectories with infinitesimal initial separation $\delta_0 \sim \mathcal{O}(10^{-5})$ to visualize exponential divergence characteristic of deterministic chaos.
## Installation
**From PyPI:**
```bash
pip install kalimusada
```
**From source:**
```bash
git clone https://github.com/sandyherho/kalimusada.git
cd kalimusada
pip install -e .
```
## Quick start
**CLI:**
```bash
kalimusada case1 # run standard chaos scenario
kalimusada --all # run all test cases
```
**Python API:**
```python
from kalimusada import MaChenSolver, MaChenSystem
system = MaChenSystem(a=0.9, b=0.2, c=1.2)
solver = MaChenSolver()
result = solver.solve(
system=system,
init_A=[1.0, 2.0, 0.5],
init_B=[1.00001, 2.0, 0.5],
t_span=(0, 250),
n_points=100000
)
print(f"Max divergence: {result['max_euclidean_distance']:.6f}")
```
## Features
- High-precision ODE integration (LSODA)
- Dual trajectory sensitivity analysis
- Error metrics: Euclidean distance, RMSE, log divergence
- Output formats: CSV, NetCDF, PNG, GIF
## License
MIT © Sandy H. S. Herho
## Citation
```bibtex
@software{herho2025_kalimusada,
title = {kalimusada: A Python library for solving the Ma-Chen financial chaotic system},
author = {Herho, Sandy H. S.},
year = {2025},
url = {https://github.com/sandyherho/kalimusada}
}
```