Skip to content

Commit

Permalink
get flatobservations/predictions
Browse files Browse the repository at this point in the history
  • Loading branch information
Siel committed May 29, 2024
1 parent f42e00d commit aa7b915
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pharmsol"
version = "0.1.10"
version = "0.1.11"
edition = "2021"
authors = [
"Julián D. Otálvaro <[email protected]>",
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions src/simulator/likelihood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,25 @@ pub struct SubjectPredictions {
predictions: Vec<Prediction>,
flat_predictions: Array1<f64>,
flat_observations: Array1<f64>,
flat_time: Array1<f64>,
}
impl SubjectPredictions {
pub fn get_predictions(&self) -> &Vec<Prediction> {
&self.predictions
}

pub fn flat_observations(&self) -> Vec<f64> {
self.flat_observations.to_vec()
}

pub fn flat_predictions(&self) -> Vec<f64> {
self.flat_predictions.to_vec()
}

pub fn flat_time(&self) -> Vec<f64> {
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<f64> = self
Expand Down Expand Up @@ -49,6 +62,7 @@ impl From<Vec<Prediction>> 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,
}
}
Expand Down

0 comments on commit aa7b915

Please sign in to comment.