pub fn calculate_interval_auc_per_observation(
subject: &Subject,
dense_times: &[f64],
dense_predictions: &[f64],
obs_times: &[f64],
) -> Vec<f64>Expand description
Calculate interval AUC for each observation independently
For each observation at time t_i, calculates AUC from the last dose before t_i to t_i. This is useful for calculating dosing interval AUC (AUCτ) in steady-state scenarios.
§Arguments
subject- Subject with doses and observationsdense_times- Complete dense time grid covering all observationsdense_predictions- Concentration predictions atdense_timesobs_times- Observation times where interval AUC should be calculated
§Returns
Vector of interval AUC values, one per observation
§Algorithm
For each observation time:
- Find the most recent dose (bolus or infusion) before that observation
- Locate that dose time in the dense grid
- Apply trapezoidal rule from dose time to observation time
- Return the interval AUC
§Example
ⓘ
let subject = Subject::builder("patient")
.bolus(0.0, 100.0, 0) // First dose
.bolus(12.0, 100.0, 0) // Second dose
.observation(24.0, 200.0, 0) // Want AUC from t=12 to t=24
.build();
// Dense grid from 0 to 24 hours
let dense_times = vec![0.0, 1.0, 2.0, ..., 24.0];
let dense_predictions = simulate_at_dense_times(...);
let obs_times = vec![24.0];
let interval_aucs = calculate_interval_auc_per_observation(
&subject, &dense_times, &dense_predictions, &obs_times
);
// interval_aucs[0] contains AUC from 12.0 to 24.0