jojo- / mipfp

Multidimensional Iterative Proportional Fitting and Alternative Models
GNU General Public License v2.0
21 stars 8 forks source link

Error of last margin Ipfp #5

Closed okrebs closed 3 years ago

okrebs commented 4 years ago

Hi again,

I noticed that even for small problems using the current Ipfp function "error.margins" for the last margin is not always precisely equal to 0, which it should be, as it is the last margin scaled. I am not sure what causes this but I believe it must be connected to the way sweep is implemented in R together with float/double precision. This is, however, fixed in the Rcpp version. For an example see the following and the attached file. test_data.zip

load("~/test_data.RData")

library(mipfp)
result <- Ipfp(seed, target.list, target.data)
result$error.margins
  [1] 2.910383e-11 1.818989e-12

library(mipfpC)
resultC <- mipfpC::Ipfp(seed, target.list, target.data)
resultC$error.margins
  [1] 2.910383e-11 0.000000e+00
jojo- commented 3 years ago

Thanks for that. It's quite interesting. This is probably due to machine precision and does not impact the accuracy of the final results.