Entropy in LaTeX (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.
\documentclass{article}
\begin{document}
Entropy: $H(X)$
\[ H(X) = -\sum_{x \in \mathcal{X}} p(x) \log_2 p(x) \]
\end{document}Related symbols
- Mutual Information
I(X; Y) - Cross Entropy
H(p, q) - Log Likelihood
\log p(x | \theta) - Bias Vector
\mathbf{b} - Probability Distribution
p(x) - Weight Matrix
\mathbf{W}
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.
Editor LaTeX AI Terbaik, Alternatif Overleaf
Octree membantu peneliti dari 15+ universitas menulis makalah penelitian lebih cepat menggunakan AI
- Hasilkan diagram TikZ yang indah menggunakan AI
- Unggah gambar dan konversi ke LaTeX dengan mulus
- Dapatkan bantuan instan untuk menulis dan memformat makalah penelitian