A physiofunctional chronometabolic model implementation (numerical inference for glucose, stress hormones, circadian time series).
The PFun CMA Model is a generative physiological model that functionally replicates neuroendocrine dynamics โ specifically the interplay between cortisol, melatonin, and adiponectin โ and their influence on glucose metabolism across the circadian cycle.
โฅ 1024b in memory).The model decomposes glucose time series data into underlying hormonal influences:

The CMA model leverages physiological modeling principles to decompose glucose time series data into underlying hormonal influences โ specifically cortisol, melatonin, and adiponectin.
Fit the CMA model to real CGM data and extract clinically meaningful parameters:

After fitting, visualize parameters with automatically generated qualitative descriptions:

Generate realistic physiological scenarios using natural language prompts. The LLM translates qualitative descriptions into physiologically valid CMA parameters:


Interactive parameter control with live chart updates via WebSocket:


Explore the CMA parameter space with precomputed grids:

# Install
pip install pfun-cma-model
# โ or with uv โ
uv add pfun-cma-model
# Run a quick model fit
uv run pfun-cma-model fit-model --plot
# Generate a scenario via LLM
uv run pfun-cma-model generate-scenario \
--query "a healthy individual who exercises before sunrise"
# Launch the full dev server
uv run fastapi dev pfun_cma_model/app.py --port 8001
pfun-cma-model/
โโโ pfun_cma_model/ # Core Python package
โ โโโ engine/ # CMA model, fit, grid, plotting
โ โโโ routes/ # FastAPI route handlers
โ โโโ llm.py # LLM prompting logic
โ โโโ cli.py # Click CLI commands
โ โโโ security.py # Security middleware
โโโ examples/
โ โโโ notebooks/ # Jupyter notebooks
โ โโโ screenshots/ # Application screenshots
โ โโโ videos/ # Demo recordings
โโโ docs/ # This documentation (Zensical)
โโโ tests/ # Test suite
โโโ results/ # Output artifacts & databases
| Resource | Link |
|---|---|
| :material-web: Homepage | pfun.one |
| :material-play-circle: Live Demo | PFun Health Tips |
| :material-github: Source Code | pfun-health/pfun-cma-model |
| :material-file-document: Research Paper | Chronometabolic Analysis (PDF) |
| :material-api: API Swagger | http://localhost:8001/docs |
| :material-api: API ReDoc | http://localhost:8001/redoc |