A Monte Carlo simulation for Cholera risk assessment โ evaluating transboundary infection risk from Bangladesh to India
Project description
๐ฆ Cholera Risk Assessment โ Monte Carlo Simulation
A Python package for quantitative risk analysis of transboundary cholera infection from Bangladesh to India, using stochastic Monte Carlo simulation.
๐ Model Overview
The model computes the compound probability of cholera-related mortality through a chain of six risk factors:
P_final = P1 ร P2 ร P3 ร P4 ร P5 ร P6
| Step | Parameter | Description | Distribution |
|---|---|---|---|
| P1 | Outbreak Probability | Cholera outbreak in Bangladesh | Poisson: 1 โ e^(โฮปt), ฮป = 2779/(22ร12) |
| P2 | Infection Rate | Human cholera infection probability | Beta(1605, 24618) |
| P3 | False Negative (BD) | Missed cases in Bangladesh | 1 โ Uniform(0.549, 0.906) |
| P4 | False Negative (IN) | Missed cases in India | 1 โ Uniform(0.884, 0.999) |
| P5 | Exposure Risk | Unsafe water ร unsafe sanitation | 0.11 ร 0.01 = 0.0011 |
| P6 | Mortality | Case fatality rate | 0.03 |
The simulation generates 10,000 (configurable) random samples and computes:
- Expected Probability (mean)
- 90% Confidence Interval (5thโ95th percentile)
- Min/Max range
- Sensitivity analysis via Spearman's rank correlation
๐ฆ Installation
# Clone the repository
git clone https://github.com/example/cholera-risk.git
cd cholera-risk
# Install the package
pip install .
# Or install in development mode
pip install -e .
# Or install dependencies only
pip install -r requirements.txt
๐ Quick Start
Using the Class API
from cholera_risk import CholeraSimulator
# Create simulator with 10,000 samples
sim = CholeraSimulator(n_samples=10000, seed=42)
# Run the Monte Carlo simulation
results = sim.run_simulation()
# Access results
print(f"Expected Risk: {results['summary']['expected_prob']:.6e}")
print(f"90% CI: [{results['summary']['ci_5']:.2e}, {results['summary']['ci_95']:.2e}]")
Using the Convenience Function
from cholera_risk.model import quick_risk_assessment
results = quick_risk_assessment(n_samples=50000, seed=123)
print(f"Risk: {results['summary']['expected_prob']:.6e}")
Generating Visualizations
from cholera_risk import CholeraSimulator
from cholera_risk.visualization import plot_all, print_summary
sim = CholeraSimulator(n_samples=10000, seed=42)
results = sim.run_simulation()
# Print formatted summary
print_summary(results)
# Generate all plots (histogram, sensitivity, scatter)
plot_all(results, save_dir="./output_plots/")
Custom Parameters
from cholera_risk.model import CholeraSimulator, SimulationConfig
# Customize epidemiological parameters
config = SimulationConfig(
total_outbreaks=3000,
observation_years=25,
beta_alpha=2000,
beta_beta=30000,
case_fatality_rate=0.05,
)
sim = CholeraSimulator(n_samples=20000, seed=99, config=config)
results = sim.run_simulation()
๐งช Running Tests
# Run all tests
python -m pytest tests/ -v
# Run with coverage
python -m pytest tests/ -v --cov=cholera_risk --cov-report=term-missing
๐ Directory Structure
colera/
โโโ cholera_risk/ # The actual Python package
โ โโโ __init__.py # Package init, exports CholeraSimulator
โ โโโ model.py # Core simulation logic (math & stats)
โ โโโ visualization.py # Plotting functions (matplotlib/seaborn)
โโโ tests/ # Unit tests
โ โโโ __init__.py
โ โโโ test_model.py # 25+ tests for correctness
โโโ app.py # Original monolithic script (reference)
โโโ index.php # PHP web application version
โโโ README.md # This file
โโโ requirements.txt # Python dependencies
โโโ setup.py # Package installation script
๐ Output Example
=================================================================
CHOLERA RISK ASSESSMENT โ Monte Carlo Simulation Results
=================================================================
Samples: 10,000
Random Seed: 42
ฮป (Poisson rate): 10.5265
-----------------------------------------------------------------
Expected Probability: 3.207426e-08
Median: 2.450000e-08
90% CI: [3.16e-09, 7.74e-08]
Minimum: 2.67e-10
Maximum: 1.05e-07
-----------------------------------------------------------------
Sensitivity Analysis (Spearman ฯ):
P2 (Infection Rate): ฯ = 0.1234
P3 (FN Bangladesh): ฯ = 0.3456
P4 (FN India): ฯ = 0.5678
=================================================================
๐ฌ Methodology
- Monte Carlo Simulation: Generates thousands of random scenarios by sampling each stochastic input from its probability distribution
- Beta Distribution (P2): Models the uncertainty in human infection rates using Bayesian parameters derived from epidemiological data
- Uniform Distributions (P3, P4): Represent the range of CholKit RDT diagnostic sensitivity
- Spearman Rank Correlation: Non-parametric measure of how strongly each input drives variations in the output
๐ License
MIT License โ see LICENSE for details.
๐ฅ Authors
- Navnath Kamble โ navnathkamble0007@gmail.com
- Yamini Madugu โ maduguyamini63662@gmail.com
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cholera_risk-0.1.0.tar.gz.
File metadata
- Download URL: cholera_risk-0.1.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e8ae4b5822b1b9df2d02fdbf1e6c45d4da6212b7a5573f295ac6e1f6b974d0d
|
|
| MD5 |
f1ffe095927ec74201cfa623fc894529
|
|
| BLAKE2b-256 |
1579fa5b00db7cf3cdce0df6cacfaaa58f7578b98ffd9d8549688e4884dcc2a3
|
File details
Details for the file cholera_risk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cholera_risk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a48d0fe293452f3d20f51396f46015a6bfd24cd3934ce3e4c9ac1395199a67c
|
|
| MD5 |
4861fbd97ea0e6283f253cff2410d28b
|
|
| BLAKE2b-256 |
2d36f9f505ca707c966cae086394b000539ba3b24a364c6ca1bf68395185cbca
|