title: Hoeffding's lemma
text: # Hoeffding's lemma
  
  In probability theory, Hoeffding's lemma is an inequality that bounds the moment-generating function of any bounded random variable. It is named after the Finnish–American mathematical statistician Wassily Hoeffding.
  
  The proof of Hoeffding's lemma uses Taylor's theorem and Jensen's inequality. Hoeffding's lemma is itself used in the proof of McDiarmid's inequality.
  
  ## Statement of the lemma
  
  Let X be any real-valued random variable such that $a\leq X\leq b$ almost surely, i.e. with probability one. Then, for all $\lambda \in \mathbb {R}$,
  
      $\mathbb {E} \left[e^{\lambda X}\right]\leq \exp {\Big\lambda \mathbb {E} [X]+{\frac {\lambda ^{2}(b-a)^{2}}{8}}{\Big )},$
  
  or equivalently,
  
      $\mathbb {E} \left[e^{\lambda (X-\mathbb {E} [X])}\right]\leq \exp {\Big{\frac {\lambda ^{2}(b-a)^{2}}{8}}{\Big )}.$
  
  ## Proof
  
  Without loss of generality, by replacing $X$ by $X-\mathbb {E} [X]$, we can assume $\mathbb {E} [X]=0$, so that $a\leq 0\leq b$.
  
  Since $e^{\lambda x}$ is a convex function of $x$, we have that for all $x\in [a,b]$,
  
      $e^{\lambda x}\leq {\frac {b-x}{b-a}}e^{\lambda a}+{\frac {x-a}{b-a}}e^{\lambda b}$
  
  So,
  
      ${\begin{aligned}\mathbb {E} \left[e^{\lambda X}\right]&\leq {\frac {b-\mathbb {E} [X]}{b-a}}e^{\lambda a}+{\frac {\mathbb {E} [X]-a}{b-a}}e^{\lambda b}\\&={\frac {b}{b-a}}e^{\lambda a}+{\frac {-a}{b-a}}e^{\lambda b}\\&=e^{L(\lambda (b-a))},\end{aligned}}$
  
  where $L(h)={\frac {ha}{b-a}}+\ln(1+{\frac {a-e^{h}a}{b-a}})$. By computing derivatives, we find
  
      $L(0)=L'(0)=0$ and $L''(h)=-{\frac {abe^{h}}{(b-ae^{h})^{2}}}$.
  
  From the AMGM inequality we thus see that $L''(h)\leq {\frac {1}{4}}$ for all $h$, and thus, from Taylor's theorem, there is some $0\leq \theta \leq 1$ such that
  
      $L(h)=L(0)+hL'(0)+{\frac {1}{2}}h^{2}L''(h\theta )\leq {\frac {1}{8}}h^{2}.$
  
  Thus, $\mathbb {E} \left[e^{\lambda X}\right]\leq e^{{\frac {1}{8}}\lambda ^{2}(b-a)^{2}}$.
  
  