opendose_poppk.population
opendose_poppk.population
Population simulation with covariates.
Classes
PopulationSimulator : Monte Carlo simulation of heterogeneous populations
- class opendose_poppk.population.PopulationSimulator(pk: PKModel | None = None, pd: PDModel | None = None, covariate_model: CovariateModel | None = None, dose: float = 1000.0)
Bases:
objectMonte Carlo simulation of heterogeneous population with covariates.
Integrates PKModel + PDModel + CovariateModel to generate individual PK/PD profiles with realistic covariate distributions.
Example
>>> pk = PKModel(F=0.8, ka=1.8, ke=0.28, Vd=65) >>> pd = PDModel(EC50=10.0, n=1.5) >>> sim = PopulationSimulator(pk, pd, dose=1000.0) >>> res = sim.run(n_subjects=1000, t_max=12.0, ... covariates={"weight": ("normal", 70, 15), ... "crcl": ("normal", 90, 30)})
- run(n_subjects: int = 1000, t_max: float = 24.0, n_points: int = 200, covariates: dict | None = None, seed: int = 42) dict
Execute Monte Carlo simulation.
- Parameters:
n_subjects (simulated population size)
t_max (final time (h))
n_points (number of points in time curve)
covariates (covariate distributions.) – Format: {“name”: (“type”, p1, p2)} Types: “normal”, “uniform”, “lognormal” Example: {“weight”: (“normal”, 70, 15)}
seed (random seed)
- Returns:
percentiles_pd, covariates_sim
- Return type:
dict with t, pk_profiles, pd_profiles, percentiles_pk,
- simulate(n: int = 10) list[ndarray]
Legacy compatibility method: returns list of profiles.
This simplifies testing - just check the array size.