Expectation in LaTeX (\mathbb{E}[X])

E[X]\mathbb{E}[X]
LaTeX command
\mathbb{E}[X]
Package
Add to your preamble:\usepackage{amssymb}
Mode
Math mode only

Where it is used

Expected value of a random variable X, written with a blackboard-bold E.

Expectation is the mean of X weighted by its distribution, \mathbb{E}[X] = \sum_x x\,p(x) or \int x f(x)\,dx. Machine learning papers use it everywhere, often with a subscript naming the distribution: \mathbb{E}_{x \sim p}[\ell(x)]. Square brackets are conventional, and \left[ \right] or \bigl[ \bigr] help when the argument contains fractions. The blackboard E sets the operator apart from an energy E or an edge set E. Linearity, \mathbb{E}[aX + bY] = a\mathbb{E}[X] + b\mathbb{E}[Y], holds even without independence, which is why it is used so freely.

Also listed under: Machine Learning at AI

Minimal compilable example

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

Ex∼p[f(x)]=∫f(x) p(x) dx\mathbb{E}_{x \sim p}[f(x)] = \int f(x)\, p(x)\, dx
\documentclass{article}
\usepackage{amssymb}
\begin{document}
Expectation: $\mathbb{E}[X]$

\[ \mathbb{E}_{x \sim p}[f(x)] = \int f(x)\, p(x)\, dx \]
\end{document}

Related symbols

All Probability at Statistics →

Frequently asked questions

How do I write Expectation in LaTeX?
Type \mathbb{E}[X] in math mode, for example $\mathbb{E}_{x \sim p}[f(x)] = \int f(x)\, p(x)\, dx$. Load amssymb first with \usepackage{amssymb}.
Which package do I need for \mathbb{E}[X]?
\mathbb{E}[X] needs amssymb: add \usepackage{amssymb} to your preamble before the document starts.
Can I use \mathbb{E}[X] in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\mathbb{E}[X]$ in running text.
Math poweredSumulat ng LaTeX gamit ang AI

Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf

Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI

  • Gumawa ng magagandang TikZ diagrams gamit ang AI
  • Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
  • Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers