# Mutual information versus correlation

Why and when we should use Mutual Information over statistical correlation measurements such as "Pearson", "spearman", or "Kendall's tau" ?

Let's consider one fundamental concept of (linear) correlation, covariance (which is Pearson's correlation coefficient "un-standardized"). For two discrete random variables $X$ and $Y$ with probability mass functions $p(x)$, $p(y)$ and joint pmf $p(x,y)$ we have

$$\operatorname{Cov}(X,Y) = E(XY) - E(X)E(Y) = \sum_{x,y}p(x,y)xy - \left(\sum_xp(x)x\right)\cdot \left(\sum_yp(y)y\right)$$

$$\Rightarrow \operatorname{Cov}(X,Y) = \sum_{x,y}\left[p(x,y)-p(x)p(y)\right]xy$$

The Mutual Information between the two is defined as

$$I(X,Y) = E\left (\ln \frac{p(x,y)}{p(x)p(y)}\right)=\sum_{x,y}p(x,y)\left[\ln p(x,y)-\ln p(x)p(y)\right]$$

Compare the two: each contains a point-wise "measure" of "the distance of the two rv's from independence" as it is expressed by the distance of the joint pmf from the product of the marginal pmf's: the $\operatorname{Cov}(X,Y)$ has it as difference of levels, while $I(X,Y)$ has it as difference of logarithms.

And what do these measures do? In $\operatorname{Cov}(X,Y)$ they create a weighted sum of the product of the two random variables. In $I(X,Y)$ they create a weighted sum of their joint probabilities.

So with $\operatorname{Cov}(X,Y)$ we look at what non-independence does to their product, while in $I(X,Y)$ we look at what non-independence does to their joint probability distribution.

Reversely, $I(X,Y)$ is the average value of the logarithmic measure of distance from independence, while $\operatorname{Cov}(X,Y)$ is the weighted value of the levels-measure of distance from independence, weighted by the product of the two rv's.

So the two are not antagonistic—they are complementary, describing different aspects of the association between two random variables. One could comment that Mutual Information "is not concerned" whether the association is linear or not, while Covariance may be zero and the variables may still be stochastically dependent. On the other hand, Covariance can be calculated directly from a data sample without the need to actually know the probability distributions involved (since it is an expression involving moments of the distribution), while Mutual Information requires knowledge of the distributions, whose estimation, if unknown, is a much more delicate and uncertain work compared to the estimation of Covariance.

• I was asking myself the same question but I have not completely understood the answer. @ Alecos Papadopoulos: I understood that the dependance measured is not the same, okay. So for what kind of relations beetween X and Y should we prefer mutual information I(X,Y) rather than Cov(X,Y)? I had a strange example recently where Y was almost linearly dependent on X (it was nearly a straight line in a scatter plot) and Corr(X,Y) was equal to 0.87 whereas I(X,Y) was equal to 0.45. So is there clearly some cases where one indicator should be choosen over the other one? Thanks for helping! – Gandhi91 Mar 25 '14 at 19:47
• @Gandhi91 What was the entropy of $X$, $H(X)$ in this specific case? – Alecos Papadopoulos Mar 30 '14 at 0:59
• This is a great and very clear answer. I was wondering if you have a readily available example where cov is 0, but pmi is not. – thang Jun 11 '17 at 23:54
• @GENIVI-LEARNER In the context of my answer "point-wise" means that deviations are measured point by point (i.e. value per value that the rv takes). And no, it is not deviation from the mean here, this is clearly stated in my answer. It is deviation from the Independence relation. – Alecos Papadopoulos Feb 18 at 19:39

Here's an example.

In these two plots the correlation coefficient is zero. But we can get high shared mutual information even when the correlation is zero.

In the first, I see that if I have a high or low value of X then I'm likely to get a high value of Y. But if the value of X is moderate then I have a low value of Y. The first plot holds information about the mutual information shared by X and Y. In the second plot, X tells me nothing about Y. Mutual information is a distance between two probability distributions. Correlation is a linear distance between two random variables.

You can have a mutual information between any two probabilities defined for a set of symbols, while you cannot have a correlation between symbols that cannot naturally be mapped into a R^N space.

On the other hand, the mutual information does not make assumptions about some properties of the variables... If you are working with variables that are smooth, correlation may tell you more about them; for instance if their relationship is monotonic.

If you have some prior information, then you may be able to switch from one to another; in medical records you can map the symbols "has genotype A" as 1 and "does not have genotype A" into 0 and 1 values and see if this has some form of correlation with one sickness or another. Similarly, you can take a variable that is continuous (ex: salary), convert it into discrete categories and compute the mutual information between those categories and another set of symbols.

• Correlation isn't a linear function. Should it say that correlation is a measure of the linear relationship between random variables? – Matthew Gunn Oct 20 '16 at 9:33
• I think this: "You can have a mutual information between any two probabilities defined for a set of symbols, while you cannot have a correlation between symbols that cannot naturally be mapped into a R^N space" is probably the key. Corr doesn't make sense if you don't have a complete random variable; however, pmi makes sense even with just the pdf and sigma (the space). This is why in many applications where RVs don't make sense (e.g. NLP), pmi is used. – thang Jun 12 '17 at 0:02

Although both of them are a measure of relationship between features, the MI is more general than correlation coefficient (CE) sine the CE is only able to takes into account linear relationships but the MI can also handle non-linear relationships.

• That's not true. The Pearson correlation coefficient assumes normality and linearity of two random variables, alternatives like the non-parametric Spearman's do not. There only monotonicity between the two rvs is assumed. – meow Aug 2 '19 at 17:01