feat(factor): implement TruncFactor with cached evidence
EP truncation factor that operates on a diff variable. Stores its outgoing message so the cavity computation produces the correct EP message on each propagation. The first propagation caches the evidence contribution (cdf-bounded probability) for log_evidence(). Promotes lib::cdf to pub(crate) so the factor can use it.
This commit is contained in:
@@ -163,7 +163,7 @@ fn compute_margin(p_draw: f64, sd: f64) -> f64 {
|
||||
ppf(0.5 - p_draw / 2.0, 0.0, sd).abs()
|
||||
}
|
||||
|
||||
fn cdf(x: f64, mu: f64, sigma: f64) -> f64 {
|
||||
pub(crate) fn cdf(x: f64, mu: f64, sigma: f64) -> f64 {
|
||||
let z = -(x - mu) / (sigma * SQRT_2);
|
||||
|
||||
0.5 * erfc(z)
|
||||
|
||||
Reference in New Issue
Block a user