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: التعلم الآلي والذكاء الاصطناعي

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 الاحتمالات والإحصاء →

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 poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf

يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي

  • أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
  • ارفع صورة وحولها إلى LaTeX بسلاسة
  • احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث