Move functions around

This commit is contained in:
2023-01-12 10:03:26 +01:00
parent 0598531547
commit ababb58055

View File

@@ -224,28 +224,6 @@ impl SumFactor {
}
}
fn v_win(t: f64, e: f64) -> f64 {
math::pdf(t - e) / math::cdf(t - e)
}
fn w_win(t: f64, e: f64) -> f64 {
let vwin = v_win(t, e);
vwin * (vwin + t - e)
}
fn v_draw(t: f64, e: f64) -> f64 {
(math::pdf(-e - t) - math::pdf(e - t)) / (math::cdf(e - t) - math::cdf(-e - t))
}
fn w_draw(t: f64, e: f64) -> f64 {
let vdraw = v_draw(t, e);
let n = (vdraw * vdraw) + ((e - t) * math::pdf(e - t) + (e + t) * math::pdf(e + t));
let d = math::cdf(e - t) - math::cdf(-e - t);
n / d
}
pub struct TruncateFactor {
variable_msg: MessageId,
variable: VariableId,
@@ -319,3 +297,25 @@ impl TruncateFactor {
delta
}
}
fn v_win(t: f64, e: f64) -> f64 {
math::pdf(t - e) / math::cdf(t - e)
}
fn w_win(t: f64, e: f64) -> f64 {
let vwin = v_win(t, e);
vwin * (vwin + t - e)
}
fn v_draw(t: f64, e: f64) -> f64 {
(math::pdf(-e - t) - math::pdf(e - t)) / (math::cdf(e - t) - math::cdf(-e - t))
}
fn w_draw(t: f64, e: f64) -> f64 {
let vdraw = v_draw(t, e);
let n = (vdraw * vdraw) + ((e - t) * math::pdf(e - t) + (e + t) * math::pdf(e + t));
let d = math::cdf(e - t) - math::cdf(-e - t);
n / d
}