refactor: Remove likelihood calculation - #291
Conversation
|
|
||
| /// Calculate the log-likelihood of the predictions given an error model. | ||
| /// | ||
| /// This is numerically more stable than computing the likelihood and taking its log, | ||
| /// especially for extreme values or many observations. | ||
| /// | ||
| /// # Parameters | ||
| /// - `error_models`: The error models for computing observation variance | ||
| /// | ||
| /// # Returns | ||
| /// The sum of log-likelihoods for all predictions | ||
| fn log_likelihood(&self, error_models: &AssayErrorModels) -> Result<f64, PharmsolError>; | ||
| /// Visit each effective prediction without requiring callers to own a `Vec`. | ||
| fn for_each_prediction(&self, mut f: impl FnMut(&Prediction)) { | ||
| let predictions = self.get_predictions(); | ||
| for prediction in &predictions { | ||
| f(prediction); | ||
| } | ||
| } |
There was a problem hiding this comment.
Is this preferred over implementing a mutable iterator?
There was a problem hiding this comment.
I prefer keeping for_each_prediction on the generic trait. SubjectPredictions can borrow stored points, but the SDE Array2<Prediction> implementation synthesizes effective mean predictions, so a generic mutable iterator cannot represent both consistently. A concrete mutable accessor on SubjectPredictions can be added later if a real mutation use case appears.
| //! metadata, and NCA. Estimation crates own scoring, objectives, priors, | ||
| //! algorithms, diagnostics, covariance, and fit semantics. |
There was a problem hiding this comment.
| //! metadata, and NCA. Estimation crates own scoring, objectives, priors, | |
| //! algorithms, diagnostics, covariance, and fit semantics. | |
| //! metadata, and NCA. |
There was a problem hiding this comment.
It seems like the documentation is leaking prompt details
There was a problem hiding this comment.
Agreed with simplifying this. I removed the exhaustive ownership list and replaced it with a concise scope statement: pharmsol provides model execution and prediction generation, while scoring and estimation are handled downstream.
|
|
||
| ## [0.28.1](https://github.com/LAPKB/pharmsol/compare/pharmsol-v0.28.0...pharmsol-v0.28.1) - 2026-07-13 | ||
| ### Added | ||
|
|
||
| ### Fixed | ||
| - Add a caller-controlled, simulation-neutral SDE particle session that pauses | ||
| at observation boundaries and can resume with retained or replaced states. | ||
| - Add focused Criterion coverage for standard SDE prediction and particle-session | ||
| retain/select paths. | ||
|
|
||
| ### Removed | ||
|
|
||
| - Remove equation-level and prediction-container observation evaluation APIs; | ||
| downstream fitting crates now generate predictions with pharmsol and evaluate | ||
| observations themselves. | ||
| - Remove residual-distribution declarations, estimator caches, and parameter | ||
| optimization helpers from pharmsol's public API. | ||
|
|
||
| ### Changed | ||
|
|
||
| - Fix data expansion ([#282](https://github.com/LAPKB/pharmsol/pull/282)) | ||
| - Relocate the existing data-only `ErrorPoly` DTO while preserving its public | ||
| path and unchanged C0-C3 transport through observations and predictions. | ||
| As before, incomplete C0-C3 rows do not create an `ErrorPoly` value. | ||
| - Keep analytical, ODE, and SDE execution focused exclusively on simulation and | ||
| prediction generation, including simulation-only examples and benchmarks. | ||
| - Run the source-scoped simulation ownership check in CI, including untracked | ||
| source files during local use. |
There was a problem hiding this comment.
PRs should not modify CHANGELOG directly
0b1ab2d to
027fd4d
Compare
|
…traction-v2 # Conflicts: # src/dsl/native.rs # src/simulator/equation/metadata.rs # src/simulator/equation/mod.rs
Massive refactor
| #[serde(default, deserialize_with = "deserialize_option_censor")] | ||
| cens: Option<Censor>, | ||
| /// First element of the error polynomial | ||
| /// C0 observation coefficient |
There was a problem hiding this comment.
Its better to use polynomial coefficient, i.e. what it is
|
|
||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// Four floating-point coefficients attached to an observation. |
There was a problem hiding this comment.
Error polynomial coefficients, no need to specify float
| self.c2 | ||
| } | ||
|
|
||
| /// Get C3. |
There was a problem hiding this comment.
I dont think we need accessors for each coefficient, a tuple of all 4 should be good
| time: f64, | ||
| value: Option<f64>, | ||
| outeq: OutputLabel, | ||
| #[serde(default, alias = "coefficients")] |
| //! - [`Covariate`] and [`Covariates`] for time-varying subject characteristics. | ||
| //! - [`ErrorModel`], [`ResidualErrorModel`], and [`ObservationError`] for the | ||
| //! different error surfaces used by downstream workflows. | ||
| //! - [`ErrorPoly`] for the transport-neutral Pmetrics C0-C3 values attached to |
There was a problem hiding this comment.
Transport-neutral sounds funny
| @@ -38,12 +38,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
|
|
|||
| ### Added | |||
|
|
|||
There was a problem hiding this comment.
Changelog is auto generated
* refactor: Update prediction structure * feat: Refactor Prediction structures
No description provided.