Samples are drawn from x and a related y, then binned into a 22×22 2D histogram to estimate the joint probability p(x,y) and the marginals p(x), p(y). Mutual information is computed directly from those bin counts:
I(X;Y) = Σ p(x,y) · log2( p(x,y) / (p(x)·p(y)) )
Pearson r is computed on the same raw samples for direct comparison. Correlation only detects a straight-line trend and can sit near zero for strongly dependent variables (a quadratic curve, a ring), while mutual information stays high in exactly those cases because it captures any reduction in uncertainty, not just a linear one. Heatmap cells glow brighter where the joint density exceeds what independence would predict — those are exactly the cells contributing positive mutual information.
- Shuffle Y — randomly permutes the y-values while keeping both marginal distributions identical, destroying the dependence. Mutual information collapses toward the shuffled baseline even though each variable alone looks unchanged.
- Resample — draws a fresh set of points from the current relationship.