[Rd] round off errors? (PR#13918)
claus.henry at gmx.de
claus.henry at gmx.de
Sat Aug 29 09:35:11 CEST 2009
Full_Name: Claus Pastor
Version: 2.9.2
OS: Windows XP
Submission from: (NULL) (82.113.106.4)
I use the following function to compute MutualInformation Matrix of factorial
members of a dataframe. I use package minet for this:
my.MI = function(test) {
## die Diagonale gibt die Entropien, Teile durch entropy von y und du erhälst
den Zusammenhang
## kenne X und sage daraus y voraus
require(minet)
MI.matrix = matrix(0,nrow=length(test),ncol=length(test),dimnames=list(names(test),names(test)))
for (i in 1:length(test)) {
for (j in 1:length(test)) {
temp = na.omit(test[,c(i,j)])
MI = build.mim(temp)
p.i = prop.table(table(temp[,1]))
p.j = prop.table(table(temp[,2]))
H.i = sum(-p.i*log(p.i))
H.j = sum(-p.j*log(p.j))
MI.matrix[i,j] = MI[1,2]/H.j
MI.matrix[j,i] = MI[1,2]/H.i
}
}
return(MI.matrix)
}
The function works well under R 2.8.
Under R2.9.2 it produces Mutual Information values (MI) of more than 1 (e.g.
1.000013) which are not allowed. MI is in [0:1]. I suppose there are rounding
errors anywhere in the new R 2.9.2.
More information about the R-devel
mailing list