phylo42 / IPK

Inference of phylo-k-mers
MIT License
4 stars 1 forks source link

incorrect threshold due to lack of float precision ? #12

Closed blinard-BIOINFO closed 11 months ago

blinard-BIOINFO commented 1 year ago

This is a general problem due to the fact that pow(float,float) is not precise enough ?

The computed threshold return a float superior to the expected value. Below, k=4, omega=8. Expected thresold = (8/20)⁴ = 0.0256

# I get the values from xpas db
for (const auto& [f, p, m] : *entries)
[...]

# get the threshold in the xpas way, this return a float
auto _thr = xpas::score_threshold(_db.omega(), _db.kmer_size());
auto _thr_log = std::log10(_thr);   

# for some reason, xpas return a float threshold > to the expected value
# p = -1.59176004 
# _thr = 0.0256000012     (why ?)
# _thr_log = -1.59176004
nromashchenko commented 11 months ago

This the reality of IEEE 754. The best you can do is to ignore it. Please refer to these informative illustrations: one, two, three.