Entropy in LaTeX (H(X))

H(X)H(X)
LaTeX command
H(X)
Package
No package needed: built into LaTeX
Mode
Text and math mode

Where it is used

Shannon entropy of a random variable X: the average uncertainty, or information content, of its outcomes.

Entropy is H(X) = -\sum_x p(x) \log p(x), measured in bits with \log_2 and in nats with \ln. It is maximized by the uniform distribution, where H(X) = \log |\mathcal{X}|, and it appears in decision tree splitting via information gain and in maximum-entropy RL. Related quantities share the letter: conditional entropy H(Y|X), joint entropy H(X, Y), and differential entropy h(X) for continuous variables, usually in lowercase. Some papers write \mathbb{H}[X] to avoid confusion with a Hessian H or a hypothesis class.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

H(X)=−∑x∈Xp(x)log⁡2p(x)H(X) = -\sum_{x \in \mathcal{X}} p(x) \log_2 p(x)
\documentclass{article}
\begin{document}
Entropy: $H(X)$

\[ H(X) = -\sum_{x \in \mathcal{X}} p(x) \log_2 p(x) \]
\end{document}

Related symbols

All 머신러닝 및 AI →

Frequently asked questions

How do I write Entropy in LaTeX?
Type H(X) in math mode, for example $H(X) = -\sum_{x \in \mathcal{X}} p(x) \log_2 p(x)$. It works in plain LaTeX without loading any package.
Which package do I need for H(X)?
None. H(X) is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use H(X) in text mode, or only in math mode?
Both. H(X) compiles in running text as well as inside $...$; in a formula keep it in math mode so it gets math fonts and spacing.
Math poweredAI로 LaTeX 작성

최고의 AI LaTeX 편집기, Overleaf 대안

Octree는 15개 이상의 대학의 연구자들이 AI를 사용하여 논문을 더 빠르게 작성하도록 도움

  • AI로 아름다운 TikZ 다이어그램 생성
  • 이미지를 업로드하고 LaTeX로 원활하게 변환
  • 논문 작성 및 서식에 대한 즉각적인 지원 받기