psychopath/src/mis.rs
Nathan Vegdahl 3de276cbaa Make MIS routines handle infinite importance better.
Handle it like the limit case: as A approaches infinity, the
limit approaches 1.0.  Before this, we were getting NaN values.
This fixes that.
2017-10-25 07:11:24 -07:00

22 lines
394 B
Rust

#![allow(dead_code)]
pub fn balance_heuristic(a: f32, b: f32) -> f32 {
if a.is_infinite() {
a
} else {
let mis_fac = a / (a + b);
a / mis_fac
}
}
pub fn power_heuristic(a: f32, b: f32) -> f32 {
if a.is_infinite() {
a
} else {
let a2 = a * a;
let b2 = b * b;
let mis_fac = a2 / (a2 + b2);
a / mis_fac
}
}