refactor: Remove likelihood calculation - #291
Conversation
| } | ||
|
|
||
| /// Create an empty cache with the same capacity but no shared entries. | ||
| pub(crate) fn detached(&self) -> Self { |
There was a problem hiding this comment.
Can we rename to e.g. reset?
With documentation comment
/// Reset the cache
///
/// Creates a new, unique cache that is not shared with caches from potentially linked equations
There was a problem hiding this comment.
I would keep detached: this method returns a new empty cache that breaks Arc sharing, whereas reset suggests mutating the existing cache. invalidate_all() already provides the clear-in-place operation. empty_detached would also be accurate if we want a more explicit name.
|
|
||
| /// 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.
| pub struct SubjectPredictions { | ||
| predictions: Vec<Prediction>, | ||
| } |
There was a problem hiding this comment.
I know we have had this structure for some time, but I am a little torn about it.
My biggest gripe is that it is disconnected from the data and subject from and for which it was generated.
Would it make sense to have predictions as part of the data?
Or as part of the Observation? I don't know.
There was a problem hiding this comment.
I would keep predictions separate from Data and Observation: they depend on the model, parameters, and potentially RNG state, and multiple prediction sets may correspond to the same source data. SubjectPredictions now carries the subject ID and parallel occasion metadata, preserving provenance without mutating the input dataset.
| //! 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
No description provided.