0
我想计算R中的条件互信息,并使用名为infotheo的包。我用两种方法计算I(X; Y1,Y2 | Z)。第一种是使用下面的代码,R中的熵和互信息
condinformation(X$industry,cbind(X$ethnicity,X$education),S=X$gender, method="emp")
[1] -1.523344
正如我认为互信息可以被分解两个熵:I(X; Y1,Y2 | Z)= H(X | Z)-H(X | Z,Y1,Y2),我用下面的代码,
hhh<-condentropy(X$industry, Y=X$gender, method="emp")
hhh1<-condentropy(X$industry,Y=cbind(X$gender,X$ethnicity,X$education))
hhh-hhh1
[1] 0.1483363
我想知道为什么这两个给了我不同的结果?
这个问题会受益于[可重现的例子](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) –