https://github.com/policyengine/mortality
Practical mortality calculations and projections for Python
https://github.com/policyengine/mortality
Last synced: 7 months ago
JSON representation
Practical mortality calculations and projections for Python
- Host: GitHub
- URL: https://github.com/policyengine/mortality
- Owner: PolicyEngine
- Created: 2025-08-10T11:25:34.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-08-10T11:25:35.000Z (8 months ago)
- Last Synced: 2025-08-27T20:31:50.607Z (7 months ago)
- Language: Python
- Size: 51.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mortality
A practical Python package for mortality calculations and projections.
## Installation
```bash
pip install mortality
```
## Quick Start
```python
from mortality import Mortality
# Simple: just age and gender
mort = Mortality(gender="male")
print(f"Probability of death at 65: {mort.q(65):.3%}")
print(f"Life expectancy at 65: {mort.e(65):.1f} years")
# With personal factors
from mortality import MortalityFactors
mort = Mortality(
gender="female",
factors=MortalityFactors(
health="good",
income_percentile=75
)
)
print(f"Personalized life expectancy: {mort.e(65):.1f} years")
# Monte Carlo simulation
death_ages = mort.simulate(age=65, n_sims=1000)
print(f"Median death age: {np.median(death_ages):.1f}")
```
## Features
- 📊 **Simple API** - Start with just age and gender
- 🎯 **Personal Factors** - Health, income, education, lifestyle
- 📈 **Mortality Improvements** - Cohort projections built-in
- 🎲 **Monte Carlo** - Fast simulation for financial planning
- 📚 **Research-Based** - All adjustments cite peer-reviewed sources
## Documentation
See [docs](docs/) for detailed documentation.
## License
MIT