Information Theory formula reference

Cross-Entropy

Measures the expected coding cost when q is used for data distributed as p.

Open in editor
LaTeXH(p,q)=-\sum_x p(x)\log q(x)

Variables

  • p: target distribution
  • q: model distribution

How to use this formula

Measures the expected coding cost when q is used for data distributed as p.

Important notes

  • q(x) must be positive wherever p(x)>0.

Quick example

Classification loss often averages cross-entropy across examples.

Applicability, worked calculation, and verification

Assumptions and domain checks

  • q(x) must be positive wherever p(x)>0.
  • Logarithm arguments must be positive in the real domain, and the base must be stated when it is not implied.
  • For the Cross-Entropy, the index variable, lower bound, upper bound, and any empty-sum or empty-product convention must be clear.
  • State the logarithm base, probability model, and whether the reported unit is bits, nats, or another convention.

Worked example

Input

Output

Classification loss often averages cross-entropy across examples.

Common mistakes

  • Do not omit the index or bounds in Cross-Entropy; changing either one changes which terms are included.
  • Do not compare entropy or information values computed with different logarithm bases without converting the units.

Continue the workflow

Use Cross-Entropy in your own work

  1. Check the domainMatch the variables and assumptions to the problem before substituting values.
  2. Copy the exact notationPreserve grouping, signs, and exponents in H(p,q)=-\sum_x p(x)\log q(x).
  3. Edit or convertOpen the expression in the LaTeX editor, then export it for your document or web page.

Review and verification

Last reviewed: 2026-07-23

Automated quality check: Kept noindex until the missing evidence is supplied.

Formula references

Frequently asked questions

What is the Cross-Entropy used for?

Measures the expected coding cost when q is used for data distributed as p.

Can I copy this formula as LaTeX?

Yes. Copy H(p,q)=-\sum_x p(x)\log q(x) or open it in the LaTeX editor.

What should I check before using it?

Confirm that each variable, unit, domain restriction, and assumption matches the problem.

Reuse, attribution, and correction

Share this reference without losing its source

Copy a citation, permanent link, Markdown link, or self-contained embed card. Each reusable format points readers back to the maintained canonical page.

Report an issue

Search the whole reference

Symbols, formulas, guides, tools and commands

Start typing to search.

move · Enter open · Esc close