persona_db/engines/health.py
Health engine — survival, diagnoses, chronic impact, mental risk.
Ownership: Agent 2. Sibling agents may import HealthEngine.
:::info Fonte
Módulo persona_db.engines.health — 222 linhas · 1 classe(s) · 0 função(ões) pública(s). Ver no GitHub
:::
Classes
class HealthEngine
Deterministic health-process generator.
| Atributo de classe | Valor |
|---|---|
SEVERITY_LEVELS | ['leve', 'moderado', 'grave'] |
CHRONIC_DISEASES | ('diabetes', 'hipertension', 'depression') |
add_hereditary_multiplier | hereditary_multiplier |
lifetime_hazard()
@staticmethod
def lifetime_hazard(age: float, sex: str, disease: str) -> float
Annual hazard rate for disease at a given age.
All hazards are non-negative; diabetes, hipertension and depression are gated by their min_age, depression peaks between 25-44, and cancer follows a Gompertz curve.
persona_db/engines/health.py:25
survival()
@staticmethod
def survival(age: float, sex: str) -> float
Probability of surviving from birth to age, S(t) in (0, 1].
Trapezoid integral over yearly steps of the total force of mortality: base_force 0.02 (males) / 0.018 (females) plus all disease hazards.
persona_db/engines/health.py:63
hereditary_multiplier()
@staticmethod
def hereditary_multiplier(disease: str, has_predisposition: bool, base_risk: float) -> float
Genetic loading: predisposed individuals carry x1.9 the base risk.
persona_db/engines/health.py:114
simulate_diagnoses()
@staticmethod
def simulate_diagnoses(rng: SeededRNG, age: float, sex: str, predispositions: list[str] | None=None) -> list[dict]
Monte-Carlo diagnosis list for diseases in DISEASE_TRANCHES.
Acceptance via u ~ Uniform(0,1): a diagnosis is recorded when u < 1 - exp(-H) where H is the lifetime cumulative hazard, with predispositions inflating H by the hereditary multiplier.
persona_db/engines/health.py:121
mental_risk_score()
@staticmethod
def mental_risk_score(risk_factors: dict) -> float
Weighted sum of psychosocial risk factors (~0..1.3).
persona_db/engines/health.py:178
mental_disorder()
@staticmethod
def mental_disorder(rng: SeededRNG, risk_score: float) -> bool
Bernoulli draw from sigmoid(risk_score - 0.7).
persona_db/engines/health.py:194
chronic_impact()
@staticmethod
def chronic_impact(rng: SeededRNG, has_chronic: bool) -> dict
Financial/employment/relationship modifiers for chronic disease.