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.
22 lines
394 B
Rust
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
|
|
}
|
|
}
|