Home▸Data Science▸Mutual Information Lab (2D)

Mutual Information Lab (2D)

2D binned joint-distribution heatmap and scatter plot comparing Pearson correlation against mutual information as the relationship between two variables changes shape.

Data Science2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-mutual-information-lab ↗ Open standalone

This 2D companion drives the same binned mutual-information estimator as the 3D version through a plain canvas view built for reading the numbers rather than orbiting a scene: a side panel lets you pick between linear, quadratic, sine, circular and independent relationships, dial in noise and sample size, and switch between a density heatmap, a scatter plot, or both overlaid. Pearson r and mutual information update live underneath, so you can watch correlation collapse to near zero for the circular and quadratic cases while mutual information — computed straight from the 2D histogram bins — stays high, and watch both drop toward a shuffled baseline once "Shuffle Y" destroys the dependence.

⚙ Under the hood

2D binned joint-distribution heatmap and scatter plot comparing Pearson correlation against mutual information as the relationship between two variables changes shape.

mutual informationcorrelationinformation theoryjoint distributionstatisticsentropy

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

Why can Pearson correlation be zero while two variables are still strongly related?

Pearson correlation only measures the strength of a straight-line trend. A quadratic curve or a circular relationship can be a perfectly deterministic dependency with a correlation near zero, because there is no consistent linear direction to detect.

What does mutual information measure that correlation misses?

Mutual information measures how much knowing one variable reduces uncertainty about the other, regardless of the shape of the relationship. It is estimated here from a binned joint histogram and stays high for nonlinear and circular dependencies where correlation collapses to zero.

What does the Shuffle Y button demonstrate?

Shuffling y randomly permutes the y-values while keeping both marginal distributions identical, which destroys any dependence between x and y. Mutual information collapses toward its shuffled baseline even though neither variable's individual distribution changes.

What did you find?

Add reproduction steps (optional)