Use f64 instead.

This commit is contained in:
2018-10-23 14:59:58 +02:00
parent 1b840e737d
commit b4cce71df4
5 changed files with 38 additions and 38 deletions

View File

@@ -113,7 +113,7 @@ pub struct LikelihoodFactor {
id: usize,
mean: VariableId,
value: VariableId,
variance: f32,
variance: f64,
}
impl LikelihoodFactor {
@@ -122,7 +122,7 @@ impl LikelihoodFactor {
id: usize,
mean: VariableId,
value: VariableId,
variance: f32,
variance: f64,
) -> LikelihoodFactor {
if let Some(variable) = variable_arena.get_mut(mean) {
variable.attach_factor(id);
@@ -183,7 +183,7 @@ pub struct SumFactor {
id: usize,
sum: VariableId,
terms: Vec<VariableId>,
coeffs: Vec<f32>,
coeffs: Vec<f64>,
}
impl SumFactor {
@@ -192,7 +192,7 @@ impl SumFactor {
id: usize,
sum: VariableId,
terms: Vec<VariableId>,
coeffs: Vec<f32>,
coeffs: Vec<f64>,
) -> SumFactor {
if let Some(variable) = variable_arena.get_mut(sum) {
variable.attach_factor(id);
@@ -218,7 +218,7 @@ impl SumFactor {
variable: VariableId,
y: Vec<Gaussian>,
fy: Vec<Gaussian>,
a: &Vec<f32>,
a: &Vec<f64>,
) {
let size = a.len();
@@ -313,21 +313,21 @@ impl SumFactor {
}
}
fn v_win(t: f32, e: f32) -> f32 {
fn v_win(t: f64, e: f64) -> f64 {
math::pdf(t - e) / math::cdf(t - e)
}
fn w_win(t: f32, e: f32) -> f32 {
fn w_win(t: f64, e: f64) -> f64 {
let vwin = v_win(t, e);
vwin * (vwin + t - e)
}
fn v_draw(t: f32, e: f32) -> f32 {
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: f32, e: f32) -> f32 {
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);
@@ -338,7 +338,7 @@ fn w_draw(t: f32, e: f32) -> f32 {
pub struct TruncateFactor {
id: usize,
variable: VariableId,
epsilon: f32,
epsilon: f64,
draw: bool,
}
@@ -347,7 +347,7 @@ impl TruncateFactor {
variable_arena: &mut VariableArena,
id: usize,
variable: VariableId,
epsilon: f32,
epsilon: f64,
draw: bool,
) -> TruncateFactor {
if let Some(variable) = variable_arena.get_mut(variable) {