Expectation in LaTeX (\mathbb{E})

E\mathbb{E}
LaTeX command
\mathbb{E}
Package
Add to your preamble:\usepackage{amssymb}
Mode
Math mode only
Copy the Unicode character
𝔼U+1D53C

Where it is used

Blackboard bold E, the standard notation for expected value of a random variable.

Expectation appears everywhere in probability and machine learning: \mathbb{E}[X] = \sum_x x\,p(x), the risk \mathbb{E}_{(x,y)\sim\mathcal{D}}[\ell(f(x),y)], or variance as \mathbb{E}[X^2] - \mathbb{E}[X]^2. Put the distribution in a subscript to make the source of randomness explicit. Older texts use a plain roman E or \operatorname{E}; both are fine if used consistently. Note that \mathbb only provides uppercase letters, so \mathbb{e} gives garbage. Use square brackets for the argument and \left[ \right] when it contains tall fractions. Defining a macro such as \newcommand{\E}{\mathbb{E}} keeps notation uniform.

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}$

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

Related symbols

All Machine Learning & AI →

Frequently asked questions

How do I write Expectation in LaTeX?
Type \mathbb{E} 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}?
\mathbb{E} needs amssymb: add \usepackage{amssymb} to your preamble before the document starts.
Can I use \mathbb{E} in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\mathbb{E}$ in running text. If you only need the glyph in text, paste the Unicode character 𝔼 instead (with XeLaTeX or LuaLaTeX and a font that has it).
Math poweredSchrijf LaTeX met AI

Beste AI LaTeX Editor, Overleaf Alternatief

Octree helpt onderzoekers van 15+ universiteiten sneller onderzoeksartikelen schrijven met AI

  • Genereer mooie TikZ-diagrammen met AI
  • Upload afbeelding en converteer naadloos naar LaTeX
  • Krijg directe hulp bij het schrijven en opmaken van onderzoeksartikelen