diff --git a/Cargo.lock b/Cargo.lock index f3f57c0..a33cdcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -813,7 +813,7 @@ dependencies = [ [[package]] name = "pharmsol" -version = "0.1.10" +version = "0.1.11" dependencies = [ "anyhow", "argmin", diff --git a/Cargo.toml b/Cargo.toml index 86a0ff0..200773c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pharmsol" -version = "0.1.10" +version = "0.1.11" edition = "2021" authors = [ "Julián D. Otálvaro ", diff --git a/src/lib.rs b/src/lib.rs index b122250..0d1f5af 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,9 @@ pub mod prelude { } pub mod simulator { pub use crate::simulator::{ - get_population_predictions, likelihood::PopulationPredictions, Equation, + get_population_predictions, + likelihood::{PopulationPredictions, SubjectPredictions}, + Equation, }; } pub mod models { diff --git a/src/simulator/likelihood.rs b/src/simulator/likelihood.rs index 392d922..6244600 100644 --- a/src/simulator/likelihood.rs +++ b/src/simulator/likelihood.rs @@ -8,12 +8,25 @@ pub struct SubjectPredictions { predictions: Vec, flat_predictions: Array1, flat_observations: Array1, + flat_time: Array1, } impl SubjectPredictions { pub fn get_predictions(&self) -> &Vec { &self.predictions } + pub fn flat_observations(&self) -> Vec { + self.flat_observations.to_vec() + } + + pub fn flat_predictions(&self) -> Vec { + self.flat_predictions.to_vec() + } + + pub fn flat_time(&self) -> Vec { + self.flat_time.to_vec() + } + pub(crate) fn likelihood(&self, error_model: &ErrorModel) -> f64 { //TODO: This sigma should not be calculated here, we should precalculate it and inject it into the struct let sigma: Array1 = self @@ -49,6 +62,7 @@ impl From> for SubjectPredictions { Self { flat_predictions: predictions.iter().map(|p| p.prediction).collect(), flat_observations: predictions.iter().map(|p| p.observation).collect(), + flat_time: predictions.iter().map(|p| p.time).collect(), predictions, } }