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) –