pymixef.pharmacometrics package

PyMixEF pharmacometrics.

The public layer combines typed model declarations, canonical event records, deterministic ODE simulation, closed-form PK helpers, residual-error models, and explicitly scoped population-estimation primitives.

class pymixef.pharmacometrics.AdditiveError(sigma, variance_floor=np.float64(2.2250738585072014e-308))[source]

Bases: _ErrorOperations

Gaussian additive residual standard deviation.

Parameters:
  • sigma (float | int | floating | str | Any)

  • variance_floor (float)

sigma: float | int | floating | str | Any
variance_floor: float
to_dict()[source]
Return type:

dict[str, Any]

variance(prediction, parameters=None)[source]
Parameters:
  • prediction (ArrayLike)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

class pymixef.pharmacometrics.AuditEntry(code, action, row_id=None, source_row_id=None, details=<factory>)[source]

Bases: object

One machine-readable canonicalization or expansion action.

Parameters:
  • code (str)

  • action (str)

  • row_id (str | None)

  • source_row_id (str | None)

  • details (Mapping[str, Any])

code: str
action: str
row_id: str | None
source_row_id: str | None
details: Mapping[str, Any]
to_dict()[source]

Serialize the audit entry without exposing mutable internals.

Return type:

dict[str, Any]

class pymixef.pharmacometrics.CanonicalEvent(subject_id, time, evid, amount=None, amount_status=None, rate=None, duration=None, compartment=None, additional=0, interval=None, steady_state=0, mdv=1, dv=None, lloq=None, occasion=None, bioavailability=1.0, lag=0.0, covariates=<factory>, extras=<factory>, row_id='', source_row_id='', source_position=0, generated=False, generation=None)[source]

Bases: object

An immutable event in the PyMixEF canonical schema.

amount_status distinguishes a recorded amount (including zero), an explicitly unknown dose amount, and a field that is structurally not applicable to a non-dose event.

Parameters:
  • subject_id (Hashable)

  • time (float)

  • evid (EventType)

  • amount (float | None)

  • amount_status (DoseAmountStatus | str | None)

  • rate (float | None)

  • duration (float | None)

  • compartment (int | str | None)

  • additional (int)

  • interval (float | None)

  • steady_state (int)

  • mdv (int)

  • dv (float | None)

  • lloq (float | None)

  • occasion (Hashable | None)

  • bioavailability (float)

  • lag (float)

  • covariates (Mapping[str, Any])

  • extras (Mapping[str, Any])

  • row_id (str)

  • source_row_id (str)

  • source_position (int)

  • generated (bool)

  • generation (str | None)

subject_id: Hashable
time: float
evid: EventType
amount: float | None
amount_status: DoseAmountStatus | str | None
rate: float | None
duration: float | None
compartment: int | str | None
additional: int
interval: float | None
steady_state: int
mdv: int
dv: float | None
lloq: float | None
occasion: Hashable | None
bioavailability: float
lag: float
covariates: Mapping[str, Any]
extras: Mapping[str, Any]
row_id: str
source_row_id: str
source_position: int
generated: bool
generation: str | None
property ADDL
property AMT
property CMT
property DUR
property DV
property EVID
property ID
property II
property LLOQ
property MDV
property RATE
property SS
property TIME
property addl
property amt
property cmt
property effective_amount: float | None
property effective_rate: float

Infusion rate after bioavailability, or zero for a bolus.

property event_type
property id
property ii
property infusion_duration: float | None
property is_dose: bool
property is_infusion: bool
property is_observation: bool
property is_reset: bool
property kind: str
property ss
to_record()[source]

Return a mutable, uppercase-keyed record for serialization.

Return type:

dict[str, Any]

class pymixef.pharmacometrics.CombinedError(additive_sigma, proportional_sigma, power=1.0, variance_floor=np.float64(2.2250738585072014e-308))[source]

Bases: _ErrorOperations

Independent additive and prediction-dependent Gaussian errors.

Component variances are added; standard deviations are not.

Parameters:
  • additive_sigma (float | int | floating | str | Any)

  • proportional_sigma (float | int | floating | str | Any)

  • power (float | int | floating | str | Any)

  • variance_floor (float)

additive_sigma: float | int | floating | str | Any
proportional_sigma: float | int | floating | str | Any
power: float | int | floating | str | Any
variance_floor: float
classmethod from_components(first, second)[source]
Parameters:
Return type:

CombinedError

to_dict()[source]
Return type:

dict[str, Any]

variance(prediction, parameters=None)[source]
Parameters:
  • prediction (ArrayLike)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

class pymixef.pharmacometrics.CompiledModel(name, parameters=(), etas=(), states=(), symbols=(), doses=(), equations=(), observations=(), schema_version='1.0', authoring_mode='executed-python-declarations')[source]

Bases: object

Data-only pharmacometric model declaration.

Parameters:
  • name (str)

  • parameters (tuple[Param, ...])

  • etas (tuple[Eta, ...])

  • states (tuple[State, ...])

  • symbols (tuple[Symbol, ...])

  • doses (tuple[Dose, ...])

  • equations (tuple[DifferentialEquation, ...])

  • observations (tuple[Observation, ...])

  • schema_version (str)

  • authoring_mode (str)

name: str
parameters: tuple[Param, ...]
etas: tuple[Eta, ...]
states: tuple[State, ...]
symbols: tuple[Symbol, ...]
doses: tuple[Dose, ...]
equations: tuple[DifferentialEquation, ...]
observations: tuple[Observation, ...]
schema_version: str
authoring_mode: str
explain()[source]

Print the implied equations, transforms, event mappings, and units.

Return type:

str

to_dict()[source]

Serialize the complete, optimizer-independent declaration.

Return type:

dict[str, Any]

to_ir()[source]

Compile this declaration into the common, versioned ModelIR.

Only expression and residual-error operations with defined semantic mappings are accepted. Custom operations fail here rather than being reduced to an opaque string that a backend could misinterpret.

Return type:

ModelIR

validate(*, raise_on_error=False)[source]

Validate names, equation coverage, mappings, and engine readiness.

Parameters:

raise_on_error (bool)

Return type:

ModelValidation

exception pymixef.pharmacometrics.ConditionalModeError[source]

Bases: EstimationError

Raised for invalid or failed subject-level conditional objectives.

code = 'NLME-CONDITIONAL-MODE-001'
class pymixef.pharmacometrics.ConditionalModeResult(eta, objective, observation_objective, random_effect_objective, gradient, hessian, covariance, success, message, iterations, function_evaluations, gradient_norm, hessian_positive_definite, warning_codes=())[source]

Bases: object

Transparent subject-level optimizer result.

Parameters:
  • eta (NDArray[float64])

  • objective (float)

  • observation_objective (float)

  • random_effect_objective (float)

  • gradient (NDArray[float64])

  • hessian (NDArray[float64])

  • covariance (NDArray[float64] | None)

  • success (bool)

  • message (str)

  • iterations (int)

  • function_evaluations (int)

  • gradient_norm (float)

  • hessian_positive_definite (bool)

  • warning_codes (tuple[str, ...])

eta: NDArray[float64]
objective: float
observation_objective: float
random_effect_objective: float
gradient: NDArray[float64]
hessian: NDArray[float64]
covariance: NDArray[float64] | None
success: bool
message: str
iterations: int
function_evaluations: int
gradient_norm: float
hessian_positive_definite: bool
warning_codes: tuple[str, ...]
class pymixef.pharmacometrics.ConditionalObjective(observations, predict, omega, error, error_parameters=<factory>, censored=None, lower_limits=None, include_constants=True)[source]

Bases: object

FOCEI-ready subject conditional negative log joint density.

predict receives an ETA vector. Residual variance is recomputed from each resulting prediction, retaining ETA–residual-variance interaction. Missing observations (NaN) are excluded explicitly. A censored mask uses the Gaussian log-CDF at lower_limits (an M3-like contribution).

Parameters:
  • observations (NDArray[float64])

  • predict (Callable[[NDArray[float64]], ArrayLike])

  • omega (NDArray[float64])

  • error (ObservationError)

  • error_parameters (Mapping[str, float])

  • censored (NDArray[bool] | None)

  • lower_limits (NDArray[float64] | None)

  • include_constants (bool)

observations: NDArray[float64]
predict: Callable[[NDArray[float64]], ArrayLike]
omega: NDArray[float64]
error: ObservationError
error_parameters: Mapping[str, float]
censored: NDArray[bool] | None
lower_limits: NDArray[float64] | None
include_constants: bool
components(eta)[source]
Parameters:

eta (ArrayLike)

Return type:

ObjectiveComponents

property eta_dimension: int
exception pymixef.pharmacometrics.DSLValidationError[source]

Bases: ValueError

Raised when declarations do not form a valid pharmacometric model.

code = 'DSL-INVALID-001'
class pymixef.pharmacometrics.DifferentialEquation(state, expression)[source]

Bases: object

One first-order ODE declaration.

Parameters:
state: State
expression: Expr
format()[source]
Return type:

str

to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.Dose(state, amount='AMT', rate='RATE', duration='DUR', compartment='CMT', lag=None, bioavailability=None, route='iv')[source]

Bases: object

Mapping from canonical event fields to a model state.

Parameters:
  • state (State)

  • amount (str)

  • rate (str | None)

  • duration (str | None)

  • compartment (str)

  • lag (str | float | None)

  • bioavailability (str | float | None)

  • route (str)

state: State
amount: str
rate: str | None
duration: str | None
compartment: str
lag: str | float | None
bioavailability: str | float | None
route: str
classmethod into(state, *, amount='AMT', rate='RATE', duration='DUR', compartment='CMT', lag=None, bioavailability=None, route='iv')[source]

Declare how dose records enter a state.

Parameters:
  • state (State)

  • amount (str)

  • rate (str | None)

  • duration (str | None)

  • compartment (str)

  • lag (str | float | None)

  • bioavailability (str | float | None)

  • route (str)

Return type:

Dose

to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.DoseAmountStatus(*values)[source]

Bases: StrEnum

Semantic state of the dose-amount field.

RECORDED = 'recorded'
UNKNOWN = 'unknown'
NOT_APPLICABLE = 'not-applicable'
exception pymixef.pharmacometrics.EstimationError[source]

Bases: RuntimeError

Base class for pharmacometric estimation failures.

code = 'ESTIMATION-FAILED-001'
class pymixef.pharmacometrics.Eta(name, block, covariance='diagonal', level='subject')[source]

Bases: _Symbolic

A named random effect and its covariance-block declaration.

Parameters:
  • name (str)

  • block (str)

  • covariance (Literal['correlated', 'diagonal'])

  • level (str)

name: str
block: str
covariance: Literal['correlated', 'diagonal']
level: str
as_expr()[source]
Return type:

Expr

classmethod correlated(*names, block=None, level='subject')[source]
Parameters:
  • names (str)

  • block (str | None)

  • level (str)

Return type:

tuple[Eta, …]

classmethod independent(*names, block=None, level='subject')[source]
Parameters:
  • names (str)

  • block (str | None)

  • level (str)

Return type:

tuple[Eta, …]

to_dict()[source]
Return type:

dict[str, str]

class pymixef.pharmacometrics.EventSnapshot(row_id, source_row_id, subject_id, time, state, dv, mdv, lloq, occasion=None)[source]

Bases: object

State observed at a canonical observation event.

Parameters:
  • row_id (str)

  • source_row_id (str)

  • subject_id (Any)

  • time (float)

  • state (NDArray[float64])

  • dv (float | None)

  • mdv (int)

  • lloq (float | None)

  • occasion (Any)

row_id: str
source_row_id: str
subject_id: Any
time: float
state: NDArray[float64]
dv: float | None
mdv: int
lloq: float | None
occasion: Any
class pymixef.pharmacometrics.EventTable(events, audit=(), source_count=0, source_records=())[source]

Bases: Sequence[CanonicalEvent]

Immutable, deterministically ordered collection of canonical events.

Parameters:
  • events (tuple[CanonicalEvent, ...])

  • audit (tuple[AuditEntry, ...])

  • source_count (int)

  • source_records (tuple[Mapping[str, Any], ...])

events: tuple[CanonicalEvent, ...]
audit: tuple[AuditEntry, ...]
source_count: int
source_records: tuple[Mapping[str, Any], ...]
expand_additional()[source]

Materialize ADDL/II doses without mutating the source table.

The returned records have ADDL=0 so expansion is idempotent. Every generated row retains the original source_row_id and receives a deterministic <row_id>:addl:<n> row identifier.

Return type:

EventTable

expand_infusions()[source]

Add explicit infusion-stop records for finite infusions.

Explicit stops already present in the source are retained. A finite start generated from AMT/RATE/DUR gets one deterministic stop.

Return type:

EventTable

for_subject(subject_id)[source]

Return an immutable view containing one subject.

Parameters:

subject_id (Hashable)

Return type:

EventTable

classmethod from_records(records, *, covariate_columns=(), expand_additional=False, expand_infusions=False)[source]

Canonicalize mapping records or a NumPy structured array.

Calendar times are converted to UTC Unix seconds and must be timezone-aware. No input object is modified.

Parameters:
  • records (Iterable[Mapping[str, Any]] | ndarray)

  • covariate_columns (Sequence[str])

  • expand_additional (bool)

  • expand_infusions (bool)

Return type:

EventTable

provenance()[source]

Return the complete immutable audit as fresh dictionaries.

Return type:

tuple[dict[str, Any], …]

property subjects: tuple[Hashable, ...]

Subject IDs in deterministic first-occurrence order.

to_records()[source]

Return plain records suitable for pandas, Polars, Arrow, or JSON.

Return type:

list[dict[str, Any]]

to_source_records()[source]

Return fresh copies of the retained, pre-canonicalization records.

Return type:

list[dict[str, Any]]

class pymixef.pharmacometrics.EventType(*values)[source]

Bases: IntEnum

Canonical EVID values, extending the common NONMEM values.

Values 0–4 retain their familiar meaning. Values 5 and 6 are explicit PyMixEF records used for time-varying covariates and infusion stops.

OBSERVATION = 0
DOSE = 1
OTHER = 2
RESET = 3
RESET_AND_DOSE = 4
COVARIATE = 5
INFUSION_STOP = 6
exception pymixef.pharmacometrics.EventValidationError(message, *, row=None)[source]

Bases: ValueError

Raised when an event record is ambiguous or internally inconsistent.

Parameters:
  • message (str)

  • row (int | str | None)

Return type:

None

code = 'EVENT-INVALID-001'
class pymixef.pharmacometrics.Expr(operation, arguments=(), value=None, metadata=<factory>)[source]

Bases: object

An immutable symbolic expression node.

Parameters:
  • operation (str)

  • arguments (tuple[Expr, ...])

  • value (float | str | None)

  • metadata (Mapping[str, Any])

operation: str
arguments: tuple[Expr, ...]
value: float | str | None
metadata: Mapping[str, Any]
evaluate(values)[source]

Evaluate using an explicit symbol table.

This method traverses the already-built expression tree. It never evaluates source code. Missing names raise KeyError.

Parameters:

values (Mapping[str, float])

Return type:

float

format()[source]

Return a deterministic, human-readable mathematical expression.

Return type:

str

to_dict()[source]

Serialize the expression tree.

Return type:

dict[str, Any]

class pymixef.pharmacometrics.LaplacePopulationResult(objective, subject_contributions, modes, warning_codes)[source]

Bases: object

Sum of subject Laplace contributions at conditional modes.

Parameters:
  • objective (float)

  • subject_contributions (NDArray[float64])

  • modes (tuple[ConditionalModeResult, ...])

  • warning_codes (tuple[str, ...])

objective: float
subject_contributions: NDArray[float64]
modes: tuple[ConditionalModeResult, ...]
warning_codes: tuple[str, ...]
class pymixef.pharmacometrics.LogNormalError(sigma)[source]

Bases: object

Multiplicative log-normal observation error.

log(observed) ~ Normal(log(prediction), sigma). logpdf includes the Jacobian for density on the original observation scale.

Parameters:

sigma (float | int | floating | str | Any)

sigma: float | int | floating | str | Any
logpdf(observed, prediction, parameters=None)[source]
Parameters:
  • observed (ArrayLike)

  • prediction (ArrayLike)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

simulate(prediction, *, rng=None, parameters=None)[source]
Parameters:
  • prediction (ArrayLike)

  • rng (Generator | None)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

to_dict()[source]
Return type:

dict[str, Any]

variance(prediction, parameters=None)[source]
Parameters:
  • prediction (ArrayLike)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

class pymixef.pharmacometrics.ModelDefinition(function, *, name=None)[source]

Bases: object

Lazy wrapper produced by model().

Calling or compiling it executes the original Python declaration function once per call in an isolated context. This behavior is explicit in CompiledModel.authoring_mode.

Parameters:
  • function (Callable[..., Any])

  • name (str | None)

compile(*args, **kwargs)[source]
Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

CompiledModel

property declaration_signature: str
explain(*args, **kwargs)[source]
Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

str

to_dict(*args, **kwargs)[source]
Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

dict[str, Any]

to_ir(*args, **kwargs)[source]

Compile the declaration into the common versioned model IR.

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

ModelIR

validate(*args, **kwargs)[source]
Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

ModelValidation

class pymixef.pharmacometrics.ModelValidation(valid, messages, dimensions, estimator_compatibility)[source]

Bases: object

Dry-run validation report for a compiled model.

Parameters:
  • valid (bool)

  • messages (tuple[ValidationMessage, ...])

  • dimensions (Mapping[str, int])

  • estimator_compatibility (Mapping[str, bool])

valid: bool
messages: tuple[ValidationMessage, ...]
dimensions: Mapping[str, int]
estimator_compatibility: Mapping[str, bool]
raise_for_errors()[source]
Return type:

None

to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.ODEContext(parameters, covariates, infusion_rates, subject_id=None)[source]

Bases: Mapping[str, float]

Explicit dynamic inputs passed to three-argument RHS callables.

The context also implements the read-only mapping protocol by delegating to parameters. Thus both context.parameters["CL"] and the familiar shorthand context["CL"] are supported without making covariates or infusion rates implicit.

Parameters:
  • parameters (Mapping[str, float])

  • covariates (Mapping[str, Any])

  • infusion_rates (NDArray[float64])

  • subject_id (Any)

parameters: Mapping[str, float]
covariates: Mapping[str, Any]
infusion_rates: NDArray[float64]
subject_id: Any
exception pymixef.pharmacometrics.ODESimulationError(message, *, time=None, subject_id=None, details=None)[source]

Bases: RuntimeError

A structured ODE or event-processing failure.

Parameters:
  • message (str)

  • time (float | None)

  • subject_id (Any)

  • details (Mapping[str, Any] | None)

Return type:

None

code = 'ODE-SIMULATION-FAILED-001'
to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.ODESimulationResult(times, states, state_names, observations, metadata, subject_id=None, sensitivities=None, sensitivity_parameters=())[source]

Bases: object

State trajectories, event snapshots, sensitivities, and solver metadata.

Parameters:
  • times (NDArray[float64])

  • states (NDArray[float64])

  • state_names (tuple[str, ...])

  • observations (tuple[EventSnapshot, ...])

  • metadata (ODESolverMetadata)

  • subject_id (Any)

  • sensitivities (NDArray[float64] | None)

  • sensitivity_parameters (tuple[str, ...])

times: NDArray[float64]
states: NDArray[float64]
state_names: tuple[str, ...]
observations: tuple[EventSnapshot, ...]
metadata: ODESolverMetadata
subject_id: Any
sensitivities: NDArray[float64] | None
sensitivity_parameters: tuple[str, ...]
sensitivity(state, parameter)[source]

Return d state / d parameter from finite differences.

Parameters:
  • state (str | int)

  • parameter (str)

Return type:

NDArray[float64]

state(name_or_index)[source]

Return one read-only state trajectory.

Parameters:

name_or_index (str | int)

Return type:

NDArray[float64]

class pymixef.pharmacometrics.ODESolverMetadata(solver, scipy_version, rtol, atol, max_step, success, message, nfev, njev, nlu, segments, event_actions, source_events, generated_additional_doses, generated_infusion_stops, same_time_order, sensitivity_method=None, sensitivity_step=None)[source]

Bases: object

Numerical and semantic metadata retained for every successful run.

Parameters:
  • solver (str)

  • scipy_version (str)

  • rtol (float)

  • atol (tuple[float, ...])

  • max_step (float)

  • success (bool)

  • message (str)

  • nfev (int)

  • njev (int)

  • nlu (int)

  • segments (int)

  • event_actions (int)

  • source_events (int)

  • generated_additional_doses (int)

  • generated_infusion_stops (int)

  • same_time_order (tuple[str, ...])

  • sensitivity_method (str | None)

  • sensitivity_step (float | None)

solver: str
scipy_version: str
rtol: float
atol: tuple[float, ...]
max_step: float
success: bool
message: str
nfev: int
njev: int
nlu: int
segments: int
event_actions: int
source_events: int
generated_additional_doses: int
generated_infusion_stops: int
same_time_order: tuple[str, ...]
sensitivity_method: str | None
sensitivity_step: float | None
to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.ObjectiveComponents(total, observation, random_effect, predictions, variances)[source]

Bases: object

Conditional objective decomposition at one ETA value.

Parameters:
  • total (float)

  • observation (float)

  • random_effect (float)

  • predictions (NDArray[float64])

  • variances (NDArray[float64])

total: float
observation: float
random_effect: float
predictions: NDArray[float64]
variances: NDArray[float64]
class pymixef.pharmacometrics.Observation(endpoint, mean, error, censored_below=None, censored_above=None, metadata=<factory>)[source]

Bases: object

An endpoint, prediction expression, and residual-error declaration.

Parameters:
  • endpoint (str)

  • mean (Expr)

  • error (Any)

  • censored_below (str | float | None)

  • censored_above (str | float | None)

  • metadata (Mapping[str, Any])

endpoint: str
mean: Expr
error: Any
censored_below: str | float | None
censored_above: str | float | None
metadata: Mapping[str, Any]
to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.ObservationError(*args, **kwargs)[source]

Bases: Protocol

Protocol implemented by residual-error declarations.

to_dict()[source]
Return type:

dict[str, Any]

variance(prediction, parameters=None)[source]
Parameters:
  • prediction (ArrayLike)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

class pymixef.pharmacometrics.OneCompartmentPK(clearance, volume)[source]

Bases: object

Reusable parameter bundle for one-compartment closed forms.

Parameters:
  • clearance (float)

  • volume (float)

clearance: float
volume: float
infusion(time, **kwargs)[source]
Parameters:
  • time (ArrayLike)

  • kwargs (float)

Return type:

Any

iv_bolus(time, dose, **kwargs)[source]
Parameters:
  • time (ArrayLike)

  • dose (float)

  • kwargs (float)

Return type:

Any

oral(time, dose, absorption_rate, **kwargs)[source]
Parameters:
  • time (ArrayLike)

  • dose (float)

  • absorption_rate (float)

  • kwargs (float)

Return type:

Any

exception pymixef.pharmacometrics.PKValidationError[source]

Bases: ValueError

Raised when PK parameters are outside their mathematical domain.

code = 'PK-INVALID-001'
class pymixef.pharmacometrics.Param(name, init, constraint='real', lower=None, upper=None, unit=None, description=None)[source]

Bases: _Symbolic

A population parameter with an explicit natural-scale constraint.

Parameters:
  • name (str)

  • init (float)

  • constraint (Literal['real', 'positive', 'bounded'])

  • lower (float | None)

  • upper (float | None)

  • unit (str | None)

  • description (str | None)

name: str
init: float
constraint: Literal['real', 'positive', 'bounded']
lower: float | None
upper: float | None
unit: str | None
description: str | None
as_expr()[source]
Return type:

Expr

classmethod bounded(name, *, init, lower, upper, unit=None, description=None)[source]
Parameters:
  • name (str)

  • init (float)

  • lower (float)

  • upper (float)

  • unit (str | None)

  • description (str | None)

Return type:

Param

classmethod positive(name, *, init, unit=None, description=None)[source]
Parameters:
  • name (str)

  • init (float)

  • unit (str | None)

  • description (str | None)

Return type:

Param

classmethod real(name, *, init=0.0, unit=None, description=None)[source]
Parameters:
  • name (str)

  • init (float)

  • unit (str | None)

  • description (str | None)

Return type:

Param

to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.PowerError(sigma, power=1.0, variance_floor=np.float64(2.2250738585072014e-308))[source]

Bases: _ErrorOperations

Gaussian residual SD sigma * abs(prediction) ** power.

Parameters:
  • sigma (float | int | floating | str | Any)

  • power (float | int | floating | str | Any)

  • variance_floor (float)

sigma: float | int | floating | str | Any
power: float | int | floating | str | Any
variance_floor: float
to_dict()[source]
Return type:

dict[str, Any]

variance(prediction, parameters=None)[source]
Parameters:
  • prediction (ArrayLike)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

class pymixef.pharmacometrics.ProportionalError(sigma, variance_floor=np.float64(2.2250738585072014e-308))[source]

Bases: _ErrorOperations

Gaussian residual SD equal to sigma * abs(prediction).

Parameters:
  • sigma (float | int | floating | str | Any)

  • variance_floor (float)

sigma: float | int | floating | str | Any
variance_floor: float
to_dict()[source]
Return type:

dict[str, Any]

variance(prediction, parameters=None)[source]
Parameters:
  • prediction (ArrayLike)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

class pymixef.pharmacometrics.SAEMControl(iterations=1000, burn_in=300, step_exponent=0.7, mcmc_steps=2, proposal_scale=0.2, seed=20260722, keep_latent_trace=False)[source]

Bases: object

Versioned controls for the experimental SAEM kernel.

Parameters:
  • iterations (int)

  • burn_in (int)

  • step_exponent (float)

  • mcmc_steps (int)

  • proposal_scale (float)

  • seed (int)

  • keep_latent_trace (bool)

iterations: int
burn_in: int
step_exponent: float
mcmc_steps: int
proposal_scale: float
seed: int
keep_latent_trace: bool
exception pymixef.pharmacometrics.SAEMError[source]

Bases: EstimationError

Raised when the experimental SAEM kernel encounters an invalid callback.

code = 'SAEM-EXPERIMENTAL-FAILED-001'
class pymixef.pharmacometrics.SAEMProblem(initial_parameters, initial_latent, log_joint, sufficient_statistics, m_step, parameter_names=())[source]

Bases: object

Model-specific callbacks required by the experimental SAEM kernel.

log_joint(parameters, latent) must return the log of the target density up to a constant. sufficient_statistics(parameters, latent) returns a fixed-shape numeric vector/array. m_step(averaged_statistics, current_parameters) performs the exact model-specific maximization.

Parameters:
  • initial_parameters (NDArray[float64])

  • initial_latent (NDArray[float64])

  • log_joint (Callable[[NDArray[float64], NDArray[float64]], float])

  • sufficient_statistics (Callable[[NDArray[float64], NDArray[float64]], ArrayLike])

  • m_step (Callable[[NDArray[float64], NDArray[float64]], ArrayLike])

  • parameter_names (tuple[str, ...])

initial_parameters: NDArray[float64]
initial_latent: NDArray[float64]
log_joint: Callable[[NDArray[float64], NDArray[float64]], float]
sufficient_statistics: Callable[[NDArray[float64], NDArray[float64]], ArrayLike]
m_step: Callable[[NDArray[float64], NDArray[float64]], ArrayLike]
parameter_names: tuple[str, ...]
class pymixef.pharmacometrics.SAEMResult(parameters, latent, sufficient_statistics, parameter_trace, latent_trace, step_sizes, acceptance_rate, accepted, proposals, seed, burn_in, step_exponent, experimental=True, reproducibility_class='stochastic-with-monte-carlo-error', warning_codes=('SAEM-EXPERIMENTAL-001',))[source]

Bases: object

Trace and diagnostics from the explicitly experimental SAEM kernel.

Parameters:
  • parameters (NDArray[float64])

  • latent (NDArray[float64])

  • sufficient_statistics (NDArray[float64])

  • parameter_trace (NDArray[float64])

  • latent_trace (NDArray[float64] | None)

  • step_sizes (NDArray[float64])

  • acceptance_rate (float)

  • accepted (int)

  • proposals (int)

  • seed (int)

  • burn_in (int)

  • step_exponent (float)

  • experimental (bool)

  • reproducibility_class (str)

  • warning_codes (tuple[str, ...])

parameters: NDArray[float64]
latent: NDArray[float64]
sufficient_statistics: NDArray[float64]
parameter_trace: NDArray[float64]
latent_trace: NDArray[float64] | None
step_sizes: NDArray[float64]
acceptance_rate: float
accepted: int
proposals: int
seed: int
burn_in: int
step_exponent: float
experimental: bool
reproducibility_class: str
warning_codes: tuple[str, ...]
to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.SensitivityCheck(parameter_names, forward, central, maximum_scaled_difference, step)[source]

Bases: object

Finite-difference sensitivity diagnostic.

Parameters:
  • parameter_names (tuple[str, ...])

  • forward (NDArray[float64])

  • central (NDArray[float64] | None)

  • maximum_scaled_difference (float | None)

  • step (float)

parameter_names: tuple[str, ...]
forward: NDArray[float64]
central: NDArray[float64] | None
maximum_scaled_difference: float | None
step: float
class pymixef.pharmacometrics.State(name, unit=None, initial=0.0)[source]

Bases: _Symbolic

An ODE state/compartment declaration.

Parameters:
  • name (str)

  • unit (str | None)

  • initial (float)

name: str
unit: str | None
initial: float
as_expr()[source]
Return type:

Expr

derivative(expression)[source]

Declare d(state)/dt inside the active model.

Parameters:

expression (Expr | _Symbolic | int | float | number)

Return type:

DifferentialEquation

to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.Symbol(name, role='covariate', unit=None, reference=None)[source]

Bases: _Symbolic

A named covariate or external model input.

Parameters:
  • name (str)

  • role (str)

  • unit (str | None)

  • reference (float | str | None)

name: str
role: str
unit: str | None
reference: float | str | None
as_expr()[source]
Return type:

Expr

to_dict()[source]
Return type:

dict[str, Any]

class pymixef.pharmacometrics.TwoCompartmentPK(clearance, central_volume, intercompartmental_clearance, peripheral_volume)[source]

Bases: object

Reusable parameter bundle for two-compartment closed forms.

Parameters:
  • clearance (float)

  • central_volume (float)

  • intercompartmental_clearance (float)

  • peripheral_volume (float)

clearance: float
central_volume: float
intercompartmental_clearance: float
peripheral_volume: float
infusion(time, **kwargs)[source]
Parameters:
  • time (ArrayLike)

  • kwargs (float)

Return type:

Any

iv_bolus(time, dose, **kwargs)[source]
Parameters:
  • time (ArrayLike)

  • dose (float)

  • kwargs (float)

Return type:

Any

oral(time, dose, absorption_rate, **kwargs)[source]
Parameters:
  • time (ArrayLike)

  • dose (float)

  • absorption_rate (float)

  • kwargs (float)

Return type:

Any

class pymixef.pharmacometrics.TwoCompartmentRates(k10, k12, k21, alpha, beta)[source]

Bases: object

Micro- and macro-rate constants for a linear two-compartment model.

Parameters:
  • k10 (float)

  • k12 (float)

  • k21 (float)

  • alpha (float)

  • beta (float)

k10: float
k12: float
k21: float
alpha: float
beta: float
exception pymixef.pharmacometrics.UnsupportedEstimatorError(engine, *, compatible=())[source]

Bases: EstimationError

Stable error for declared but not production-ready estimators.

Parameters:
  • engine (str)

  • compatible (Sequence[str])

Return type:

None

code = 'ENGINE-UNSUPPORTED-001'
exception pymixef.pharmacometrics.UnsupportedEventSemantics(message, *, time=None, subject_id=None, details=None)[source]

Bases: ODESimulationError

Raised rather than silently approximating unsupported event semantics.

Parameters:
  • message (str)

  • time (float | None)

  • subject_id (Any)

  • details (Mapping[str, Any] | None)

Return type:

None

code = 'ODE-EVENT-UNSUPPORTED-001'
class pymixef.pharmacometrics.ValidationMessage(code, severity, message)[source]

Bases: object

One coded severity and message emitted by dry-run model validation.

Parameters:
  • code (str)

  • severity (Literal['error', 'warning', 'info'])

  • message (str)

code: str
severity: Literal['error', 'warning', 'info']
message: str
to_dict()[source]
Return type:

dict[str, str]

pymixef.pharmacometrics.additive(sigma)[source]

Declare an additive Gaussian error model.

Parameters:

sigma (float | int | floating | str | Any)

Return type:

AdditiveError

pymixef.pharmacometrics.apply_random_effects(typical_values, eta, *, names=None, relationships=None)[source]

Apply common random-effect relationships to typical values.

The default relationship is exponential, individual = typical*exp(eta). Per-parameter alternatives are additive and logit. The latter expects a typical value strictly between zero and one and adds eta on the logit scale.

Parameters:
  • typical_values (Mapping[str, float])

  • eta (Mapping[str, float] | ArrayLike)

  • names (Sequence[str] | None)

  • relationships (Mapping[str, str] | None)

Return type:

Mapping[str, float]

pymixef.pharmacometrics.as_expr(value)[source]

Convert declarations and numeric constants to an expression node.

Parameters:

value (Expr | _Symbolic | int | float | number)

Return type:

Expr

pymixef.pharmacometrics.canonicalize_events(records, *, covariate_columns=(), expand_additional=False, expand_infusions=False)[source]

Convenience wrapper around EventTable.from_records().

Parameters:
  • records (Iterable[Mapping[str, Any]] | ndarray)

  • covariate_columns (Sequence[str])

  • expand_additional (bool)

  • expand_infusions (bool)

Return type:

EventTable

pymixef.pharmacometrics.combined(additive_sigma, proportional_sigma, *, exponent=1.0)[source]

Declare an additive-plus-power residual-error model.

Parameters:
  • additive_sigma (float | int | floating | str | Any)

  • proportional_sigma (float | int | floating | str | Any)

  • exponent (float | int | floating | str | Any)

Return type:

CombinedError

pymixef.pharmacometrics.compiled_model(name, *, parameters=(), etas=(), states=(), symbols=(), doses=(), equations=(), observations=(), validate=True)[source]

Build a data-only model directly, without executing a declaration function.

Parameters:
Return type:

CompiledModel

pymixef.pharmacometrics.conditional_mode_objective(eta, *, observations, predict, omega, error, error_parameters=None, censored=None, lower_limits=None, include_constants=True)[source]

Functional interface to ConditionalObjective.

Parameters:
  • eta (ArrayLike)

  • observations (ArrayLike)

  • predict (Callable[[NDArray[float64]], ArrayLike])

  • omega (ArrayLike)

  • error (ObservationError)

  • error_parameters (Mapping[str, float] | None)

  • censored (ArrayLike | None)

  • lower_limits (ArrayLike | None)

  • include_constants (bool)

Return type:

float

pymixef.pharmacometrics.covariate(name, *, unit=None, reference=None)[source]

Declare a covariate symbol.

Parameters:
  • name (str)

  • unit (str | None)

  • reference (float | str | None)

Return type:

Symbol

pymixef.pharmacometrics.d(state, expression)[source]

Short alias for derivative().

Python does not permit the illustrative syntax d(state) = expression; PyMixEF therefore uses d(state, expression) or state.derivative(expression).

Parameters:
  • state (State)

  • expression (Expr | _Symbolic | int | float | number)

Return type:

DifferentialEquation

pymixef.pharmacometrics.derivative(state, expression)[source]

Declare a state derivative in the active model.

Parameters:
  • state (State)

  • expression (Expr | _Symbolic | int | float | number)

Return type:

DifferentialEquation

pymixef.pharmacometrics.eta_shrinkage(eta_estimates, omega)[source]

Variance-based ETA shrinkage 1 - Var(eta_hat)/diag(Omega).

The result is diagnostic and is not clipped; negative values reveal empirical ETA variance greater than the modeled population variance.

Parameters:
  • eta_estimates (ArrayLike)

  • omega (ArrayLike)

Return type:

NDArray[float64]

pymixef.pharmacometrics.exp(value)[source]

Build a symbolic exponential expression without evaluating value.

Parameters:

value (Expr | _Symbolic | int | float | number)

Return type:

Expr

pymixef.pharmacometrics.experimental_saem(problem, control=None)[source]

Run the callback-based experimental SAEM algorithm.

At iteration k the stochastic-approximation step is 1 during burn-in and (k - burn_in) ** (-step_exponent) afterward. The latent simulation is a symmetric random-walk Metropolis kernel, making its acceptance ratio explicit and auditable.

Parameters:
Return type:

SAEMResult

pymixef.pharmacometrics.find_conditional_mode(objective, initial_eta=None, *, method='BFGS', tolerance=1e-8, max_iterations=500, require_success=False)[source]

Optimize a subject ETA mode and independently inspect its Hessian.

Parameters:
  • objective (ConditionalObjective)

  • initial_eta (ArrayLike | None)

  • method (str)

  • tolerance (float)

  • max_iterations (int)

  • require_success (bool)

Return type:

ConditionalModeResult

pymixef.pharmacometrics.finite_difference_gradient(function, point, *, relative_step=np.cbrt(np.finfo(float).eps))[source]

Central finite-difference gradient for derivative verification.

Parameters:
  • function (Callable[[NDArray[float64]], float])

  • point (ArrayLike)

  • relative_step (float)

Return type:

NDArray[float64]

pymixef.pharmacometrics.finite_difference_hessian(function, point, *, relative_step=np.finfo(float).eps**0.25)[source]

Symmetric finite-difference Hessian for small conditional-mode problems.

Parameters:
  • function (Callable[[NDArray[float64]], float])

  • point (ArrayLike)

  • relative_step (float)

Return type:

NDArray[float64]

pymixef.pharmacometrics.finite_difference_sensitivities(rhs, initial_state, events, *, parameters, parameter_names=None, step=np.cbrt(np.finfo(float).eps), compare_central=False, **simulation_options)[source]

Compute forward sensitivities and optionally compare central differences.

This is a validation/debug path, not an automatic-differentiation claim. Event times are held fixed while parameter values are perturbed.

Parameters:
  • rhs (Callable[[...], ArrayLike])

  • initial_state (ArrayLike)

  • events (EventTable | Iterable[Mapping[str, Any]] | None)

  • parameters (Mapping[str, float])

  • parameter_names (Sequence[str] | None)

  • step (float)

  • compare_central (bool)

  • simulation_options (Any)

Return type:

SensitivityCheck

pymixef.pharmacometrics.fit_focei(*args, **kwargs)[source]

Refuse a production FOCEI claim until the complete engine is validated.

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

None

pymixef.pharmacometrics.interval_censored_loglikelihood(lower, upper, prediction, error, *, parameters=None)[source]

Stable log probability for an interval-censored observation.

Parameters:
  • lower (ArrayLike)

  • upper (ArrayLike)

  • prediction (ArrayLike)

  • error (ObservationError)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

pymixef.pharmacometrics.laplace_population_objective(subject_objectives, *, initial_etas=None, require_modes=True, **mode_options)[source]

Evaluate Laplace-integrated subject objectives.

This is a FOCEI-ready outer-objective component. It does not optimize or transform population parameters and is therefore not exposed as a complete FOCEI fit.

Parameters:
  • subject_objectives (Sequence[ConditionalObjective])

  • initial_etas (Sequence[ArrayLike] | None)

  • require_modes (bool)

  • mode_options (Any)

Return type:

LaplacePopulationResult

pymixef.pharmacometrics.left_censored_loglikelihood(limit, prediction, error, *, parameters=None)[source]

Stable log-CDF contribution for observations below limit.

Parameters:
  • limit (ArrayLike)

  • prediction (ArrayLike)

  • error (ObservationError)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

pymixef.pharmacometrics.log(value)[source]

Build a symbolic natural-log expression without checking its domain.

Parameters:

value (Expr | _Symbolic | int | float | number)

Return type:

Expr

pymixef.pharmacometrics.log1p(value)[source]

Build a symbolic log(1 + value) expression without evaluating it.

Parameters:

value (Expr | _Symbolic | int | float | number)

Return type:

Expr

pymixef.pharmacometrics.lognormal(sigma)[source]

Declare an original-scale log-normal error model.

Parameters:

sigma (float | int | floating | str | Any)

Return type:

LogNormalError

pymixef.pharmacometrics.model(function=None, /, *, name=None)[source]

Decorate a Python function as a lazy model declaration.

Parameters:
  • function (Callable[[...], Any] | None)

  • name (str | None)

Return type:

ModelDefinition | Callable[[Callable[[…], Any]], ModelDefinition]

pymixef.pharmacometrics.observe(endpoint, *, mean, error, censored_below=None, censored_above=None, metadata=None)[source]

Declare an observation endpoint in the active model.

Parameters:
  • endpoint (str)

  • mean (Expr | _Symbolic | int | float | number)

  • error (Any)

  • censored_below (str | float | None)

  • censored_above (str | float | None)

  • metadata (Mapping[str, Any] | None)

Return type:

Observation

pymixef.pharmacometrics.omega_from_standard_deviations(standard_deviations, correlation=None)[source]

Construct a positive-definite random-effects covariance matrix.

Parameters:
  • standard_deviations (ArrayLike)

  • correlation (ArrayLike | None)

Return type:

NDArray[float64]

pymixef.pharmacometrics.one_compartment_bolus(time, *, dose, clearance, volume, bioavailability=1.0, lag=0.0)

Concentration after a single IV bolus in a one-compartment model.

Parameters:
  • time (ArrayLike)

  • dose (float)

  • clearance (float)

  • volume (float)

  • bioavailability (float)

  • lag (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.one_compartment_infusion(time, *, clearance, volume, dose=None, rate=None, duration=None, bioavailability=1.0, start=0.0)[source]

Concentration for a finite constant-rate one-compartment infusion.

Supply any two consistent values among dose, rate, and duration. If all three are supplied, dose == rate * duration is checked.

Parameters:
  • time (ArrayLike)

  • clearance (float)

  • volume (float)

  • dose (float | None)

  • rate (float | None)

  • duration (float | None)

  • bioavailability (float)

  • start (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.one_compartment_iv_bolus(time, *, dose, clearance, volume, bioavailability=1.0, lag=0.0)[source]

Concentration after a single IV bolus in a one-compartment model.

Parameters:
  • time (ArrayLike)

  • dose (float)

  • clearance (float)

  • volume (float)

  • bioavailability (float)

  • lag (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.one_compartment_iv_infusion(time, *, clearance, volume, dose=None, rate=None, duration=None, bioavailability=1.0, start=0.0)

Concentration for a finite constant-rate one-compartment infusion.

Supply any two consistent values among dose, rate, and duration. If all three are supplied, dose == rate * duration is checked.

Parameters:
  • time (ArrayLike)

  • clearance (float)

  • volume (float)

  • dose (float | None)

  • rate (float | None)

  • duration (float | None)

  • bioavailability (float)

  • start (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.one_compartment_oral(time, *, dose, clearance, volume, absorption_rate, bioavailability=1.0, lag=0.0)[source]

Concentration after a first-order oral dose.

The numerically stable limiting expression is used when absorption and elimination rate constants are nearly equal.

Parameters:
  • time (ArrayLike)

  • dose (float)

  • clearance (float)

  • volume (float)

  • absorption_rate (float)

  • bioavailability (float)

  • lag (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.power(sigma, exponent)[source]

Declare a power residual-error model.

Parameters:
  • sigma (float | int | floating | str | Any)

  • exponent (float | int | floating | str | Any)

Return type:

PowerError

pymixef.pharmacometrics.proportional(sigma)[source]

Declare a proportional Gaussian error model.

Parameters:

sigma (float | int | floating | str | Any)

Return type:

ProportionalError

pymixef.pharmacometrics.right_censored_loglikelihood(limit, prediction, error, *, parameters=None)[source]

Stable log-survival contribution for observations above limit.

Parameters:
  • limit (ArrayLike)

  • prediction (ArrayLike)

  • error (ObservationError)

  • parameters (Mapping[str, float] | None)

Return type:

NDArray[float64]

pymixef.pharmacometrics.saem(problem, control=None)

Run the callback-based experimental SAEM algorithm.

At iteration k the stochastic-approximation step is 1 during burn-in and (k - burn_in) ** (-step_exponent) afterward. The latent simulation is a symmetric random-walk Metropolis kernel, making its acceptance ratio explicit and auditable.

Parameters:
Return type:

SAEMResult

pymixef.pharmacometrics.simulate_ode(rhs, initial_state, events=None, *, t_eval=None, parameters=None, initial_covariates=None, covariate_columns=(), state_names=None, compartment_map=None, subject_id=None, initial_time=0.0, final_time=None, method='RK45', rtol=1e-8, atol=1e-10, max_step=np.inf, sensitivity_parameters=None, sensitivity_step=np.sqrt(np.finfo(float).eps), debug_finite_difference=False)[source]

Simulate one subject with exact event-time discontinuities.

Supported RHS signatures are rhs(t, y), rhs(t, y, context) and rhs(t, y, parameters, covariates). For the three-argument form, context is an ODEContext. Infusion rates are always added to the returned state derivatives by the event manager.

Forward finite-difference sensitivities can be requested by parameter name. Set debug_finite_difference=True to compute all numeric parameter sensitivities when no explicit list is supplied.

Parameters:
  • rhs (Callable[[...], ArrayLike])

  • initial_state (ArrayLike)

  • events (EventTable | Iterable[Mapping[str, Any]] | None)

  • t_eval (ArrayLike | None)

  • parameters (Mapping[str, float] | None)

  • initial_covariates (Mapping[str, Any] | None)

  • covariate_columns (Sequence[str])

  • state_names (Sequence[str] | None)

  • compartment_map (Mapping[int | str, int | str] | None)

  • subject_id (Any)

  • initial_time (float)

  • final_time (float | None)

  • method (str)

  • rtol (float)

  • atol (float | ArrayLike)

  • max_step (float)

  • sensitivity_parameters (Sequence[str] | None)

  • sensitivity_step (float)

  • debug_finite_difference (bool)

Return type:

ODESimulationResult

pymixef.pharmacometrics.simulate_subjects(rhs, initial_state, events, **options)[source]

Deterministically simulate every subject in an event table.

Parameters:
  • rhs (Callable[[...], ArrayLike])

  • initial_state (ArrayLike)

  • events (EventTable | Iterable[Mapping[str, Any]])

  • options (Any)

Return type:

Mapping[Any, ODESimulationResult]

pymixef.pharmacometrics.sqrt(value)[source]

Build a symbolic square-root expression without checking its domain.

Parameters:

value (Expr | _Symbolic | int | float | number)

Return type:

Expr

pymixef.pharmacometrics.symbol(name, *, role='covariate', unit=None, reference=None)[source]

Declare a typed covariate or other external model input.

Parameters:
  • name (str)

  • role (str)

  • unit (str | None)

  • reference (float | str | None)

Return type:

Symbol

pymixef.pharmacometrics.two_compartment_bolus(time, *, dose, clearance, central_volume, intercompartmental_clearance, peripheral_volume, bioavailability=1.0, lag=0.0)

Central concentration after a single two-compartment IV bolus.

Parameters:
  • time (ArrayLike)

  • dose (float)

  • clearance (float)

  • central_volume (float)

  • intercompartmental_clearance (float)

  • peripheral_volume (float)

  • bioavailability (float)

  • lag (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.two_compartment_infusion(time, *, clearance, central_volume, intercompartmental_clearance, peripheral_volume, dose=None, rate=None, duration=None, bioavailability=1.0, start=0.0)[source]

Central concentration during and after a finite two-compartment infusion.

Parameters:
  • time (ArrayLike)

  • clearance (float)

  • central_volume (float)

  • intercompartmental_clearance (float)

  • peripheral_volume (float)

  • dose (float | None)

  • rate (float | None)

  • duration (float | None)

  • bioavailability (float)

  • start (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.two_compartment_iv_bolus(time, *, dose, clearance, central_volume, intercompartmental_clearance, peripheral_volume, bioavailability=1.0, lag=0.0)[source]

Central concentration after a single two-compartment IV bolus.

Parameters:
  • time (ArrayLike)

  • dose (float)

  • clearance (float)

  • central_volume (float)

  • intercompartmental_clearance (float)

  • peripheral_volume (float)

  • bioavailability (float)

  • lag (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.two_compartment_iv_infusion(time, *, clearance, central_volume, intercompartmental_clearance, peripheral_volume, dose=None, rate=None, duration=None, bioavailability=1.0, start=0.0)

Central concentration during and after a finite two-compartment infusion.

Parameters:
  • time (ArrayLike)

  • clearance (float)

  • central_volume (float)

  • intercompartmental_clearance (float)

  • peripheral_volume (float)

  • dose (float | None)

  • rate (float | None)

  • duration (float | None)

  • bioavailability (float)

  • start (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.two_compartment_oral(time, *, dose, clearance, central_volume, intercompartmental_clearance, peripheral_volume, absorption_rate, bioavailability=1.0, lag=0.0)[source]

Central concentration after first-order absorption into two compartments.

Parameters:
  • time (ArrayLike)

  • dose (float)

  • clearance (float)

  • central_volume (float)

  • intercompartmental_clearance (float)

  • peripheral_volume (float)

  • absorption_rate (float)

  • bioavailability (float)

  • lag (float)

Return type:

float | NDArray[float64]

pymixef.pharmacometrics.two_compartment_rates(*, clearance, central_volume, intercompartmental_clearance, peripheral_volume)[source]

Calculate microconstants and hybrid exponents alpha and beta.

Parameters:
  • clearance (float)

  • central_volume (float)

  • intercompartmental_clearance (float)

  • peripheral_volume (float)

Return type:

TwoCompartmentRates

Submodules