Skip to content

Instantly share code, notes, and snippets.

@coppeliaMLA
Created June 25, 2014 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coppeliaMLA/b0f1798f3749621be5dd to your computer and use it in GitHub Desktop.
Save coppeliaMLA/b0f1798f3749621be5dd to your computer and use it in GitHub Desktop.
Look at the relationship between MI and correlation for binary vars (since it's quicker than doing the maths)
#Check the relationship between correlation and mutual information for binary vars
store<-NULL
for (i in 1:1000){
prob.1<-runif(1)
prob.2<-runif(1)
x<-rbinom(10000, 1, prob.1)
y<-rbinom(10000, 1, prob.2)
c<-cor(x,y)
m<-mi.empirical(table(x,y))
store<-rbind(store, data.frame(c=c, m=m))
}
plot(store)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment