I try to use the package mpmi to calculate the mutual information between two set of continuous variables. I am confused of the source code put on GutHub: https://github.com/cran/mpmi/blob/master/src/cminjk.f95
ans = ans + log(s12(i) / (s1(i) * s2(i)))
end do
ans = ans / lv + log(dble(lv))
The s12 seems like the p(x,y)
, and s1,s2 seems like the p(x),p(y)
.
Why not multiply the p(x,y)
before log(s12(i) / (s1(i) * s2(i)))
, for the formula to calculate MI is p(x,y)*log(p(x,y)/(p(x)p(y)))
And why there is ans = ans / lv + log(dble(lv))
after finishing the summation?