saimoom / phyml

Automatically exported from code.google.com/p/phyml
GNU General Public License v2.0
0 stars 0 forks source link

Floating point error check in BEAGLE needs to be circumvented #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When the likelihood is 0.0, the log() likelihood ends up being -inf which 
subsequently causes this check to trigger:

  if (!(*outSumLogLikelihood - *outSumLogLikelihood == 0.0))
        returnCode = BEAGLE_ERROR_FLOATING_POINT;

Original issue reported on code.google.com by imran.fa...@gmail.com on 18 Sep 2013 at 3:28

GoogleCodeExporter commented 9 years ago
Where is this being triggered? Why is it an issue? Please give more details.

Original comment by ramb...@gmail.com on 29 Sep 2013 at 12:50

GoogleCodeExporter commented 9 years ago
It is being triggered at BeagleCPU4StateImpl.hpp:450 (NT models), and 
BeagleCPUImpl.hpp:1412 (AA models). It is a problem because the likelihood can 
be 0.0, thus the log() is now -inf. Subsequently the (-inf - -inf == 0.0) check 
always fails.

For the time being, I have commented out the check and it causes no issues 
(i.e. the final likelihoods between PhyML and PhyML+BEAGLE match).

Original comment by imran.fa...@gmail.com on 29 Sep 2013 at 1:07

GoogleCodeExporter commented 9 years ago
I might suggest:

   if (isnan(*outSumLogLikelihood)) { ... }

or

   if (!(*outSumLogLikelihood == *outSumLogLikelihood)) { ... }

instead.  These conditions do not fail for +/- infinity, but do fail for NaN.

Original comment by msuch...@gmail.com on 30 Sep 2013 at 9:36

GoogleCodeExporter commented 9 years ago

Original comment by imran.fa...@gmail.com on 1 Oct 2013 at 11:06