Mutual Information Calculator

Compute mutual information I(X;Y) from a joint probability table. This educational calculator shows the formula, result, and step-by-step interpretation.

ProbabilityInformation TheoryComputer Science

Calculator

What this calculator teaches

Mutual information measures how much knowing one variable reduces uncertainty about another.

Use the result as a learning aid. For classwork, still show the formula and intermediate reasoning so the final answer is not just a black-box number.

Understanding Mutual Information

Mutual information measures how much knowing one random variable reduces uncertainty about another. For discrete variables X and Y, it compares the observed joint probability p(x,y) with the product p(x)p(y) that would occur under independence. The calculator reports the result in bits because it uses logarithms base 2.

If X and Y are independent, p(x,y)=p(x)p(y) for every pair, each log ratio is 0, and the mutual information is 0 bits. Positive mutual information means the variables share statistical dependence. The measure is symmetric: I(X;Y)=I(Y;X). It is not a signed measure, so it does not distinguish positive from negative correlation.

QuantityFormula
Mutual informationI(X;Y)=Σ p(x,y) log₂[p(x,y)/(p(x)p(y))]
Entropy identityI(X;Y)=H(X)+H(Y)−H(X,Y)
IndependenceI(X;Y)=0

Counts can be used instead of already-normalized probabilities because the calculator first divides every cell by the total. Zero-probability cells contribute 0 to the sum by continuity. The table should nevertheless contain nonnegative values and consistent row lengths; a negative count or malformed table does not represent a valid joint distribution.

Interpreting the size of mutual information requires context. MI is bounded above by the smaller of H(X) and H(Y), so 0.7 bits can be very large for a low-entropy binary variable but modest for variables with many possible outcomes. A normalized comparison may therefore be useful when comparing different datasets, although several normalization conventions exist.

For a useful hand check, compute the row and column marginals first. If every joint cell equals the product of its corresponding marginals, the variables are independent and MI must be zero. At the opposite extreme, if one variable determines the other perfectly, MI equals the entropy of the determined variable. These endpoints make good tests for both data entry and software output.

Formula & Symbols

ConceptFormula or rule
Mutual informationI(X;Y) = Σ p(x,y) log₂[p(x,y)/(p(x)p(y))]

Worked example

Example: Mutual information is zero when X and Y are independent.
Example 2: An independent 2×2 table [[1,1],[1,1]] normalizes to equal probabilities and gives I=0 bits.
Example 3: A perfectly matched table [[1,0],[0,1]] gives I=1 bit when the two outcomes are equally likely.
Example 4: Scaling every count by the same factor, such as [[10,0],[0,10]], leaves I unchanged at 1 bit.
Example 5: A deterministic but imbalanced table [[3,0],[0,1]] has I=H(3/4,1/4)≈0.8113 bits.

Common mistakes

⚠️
Using the wrong input format

Keep lists comma separated, matrices as rows separated by semicolons, and modular inputs as integers.

⚠️
Ignoring assumptions

Some methods require positive probabilities, valid moduli, independent trials, or small educational input sizes.

⚠️
Treating mutual information as correlation

MI detects general dependence, including nonlinear dependence, and has no positive or negative sign.

⚠️
Using negative or inconsistent table entries

Joint probabilities or counts must be nonnegative, and every row should describe the same set of Y categories.

FAQ

Can I use decimals?
Most numerical calculators allow decimals, but modular arithmetic and coding-theory tools usually require integers or binary strings.
Is this for homework checking?
Yes. The page is designed to show both the answer and the reasoning pattern.
Why does the result sometimes say approximate?
Some probability, floating-point, and numerical methods naturally produce approximations.
Can mutual information be negative?
The theoretical value is always nonnegative. Tiny negative values in numerical software can arise only from rounding error.
Does MI equal 1 for perfect dependence?
Not always. Its maximum depends on the entropy of the variables; 1 bit is the maximum only for a balanced binary variable.
Can I enter raw counts?
Yes. Dividing all cells by the common total produces the joint probabilities used by the formula.
Why are zero cells skipped in the sum?
The limiting value of p log p as p approaches zero is zero, so zero-probability events contribute nothing.

Related calculators

These links will work after the calculators are registered in the final Math layout update.

Formula Explorer connections

Interpretation: This relationship quantifies information, representation, storage, error, search or computational performance. Assumption: Use the exact encoding, data distribution, machine representation and algorithm assumptions. Real systems also include implementation and hardware overhead.

Shannon Entropy and Information Gain Calculator →Sorting Algorithm Comparison Calculator →Binary Search Steps Calculator →Math Formula Explorer →