Skip to content

Commit

Permalink
feat(rust): Added View::logp
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidmt committed May 7, 2024
1 parent 92a85c7 commit c741c3b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lace/lace_cc/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ impl View {
.fold(0.0, |acc, ftr| acc + ftr.predictive_score_at(row_ix, k))
}

/// Compute the log probability of observing `datum` belonging to cluster `k`
/// given the data already assigned to category `k` with all component parameters
/// marginalized away
pub fn logp(&self, datum: &Datum, k: usize) -> f64 {
self.ftrs.values().map(|ftr| ftr.cpnt_logp(datum, k)).sum()
}

#[inline]
pub fn logm(&self, k: usize) -> f64 {
self.ftrs.values().map(|ftr| ftr.logm(k)).sum()
Expand Down

0 comments on commit c741c3b

Please sign in to comment.