% $Header: /cvsroot/latex-beamer/latex-beamer/examples/beamerexample5.tex,v 1.22 2004/10/08 14:02:33 tantau Exp $

\documentclass[11pt]{beamer}
\usepackage{amscd}

%\usetheme{Madrid} % Darmstadt, Boadilla


\mode<presentation> {
  \usetheme{Madrid}
  \setbeamercovered{transparent}
}

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsbsy,alltt,amsmath,times}
\usepackage{epsfig, color, graphicx, rotate, colordvi}
%\usepackage{fancybox,fancyhdr,times,subfigure}
\usepackage{hyperref, mathptmx}


\setbeamercovered{dynamic}

\newcommand{\Lang}[1]{\operatorname{\text{\textsc{#1}}}}

\newcommand{\Class}[1]{\operatorname{\mathchoice
  {\text{\sf \small #1}}
  {\text{\sf \small #1}}
  {\text{\sf #1}}
  {\text{\sf #1}}}}

\newcommand{\NumSAT}      {\text{\small\#SAT}}
\newcommand{\NumA}        {\#_{\!A}}

\newcommand{\barA}        {\,\bar{\!A}}

\newcommand{\Nat}{\mathbb{N}}
\newcommand{\Set}[1]{\{#1\}}

\newtheorem{thm}{Result}%[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{defn}[thm]{Definition}
\newtheorem{exam}{Example}%[section]
\newtheorem{rem}{Remark}

\newcommand{\cred}{\textcolor {red}}
\newcommand{\cblue}{\textcolor {blue}}
\newcommand{\cgreen}{\textcolor {green}}

\def\ul{\underline}

\def\sign{\;{\rm sign}}
\def\rank{\;{\rm rank}}
\def\disp{\displaystyle}
\def\sn{\sqrt{n}}
\def\Pr{\mathrm{P}}

\def\Cov{\;{\rm Cov}}
\def\L{\underline L}
\def\LL{\overline L}

\def\balpha{{\boldsymbol{\alpha}}}
\def\cal{\mathcal}
\def\conas{\stackrel{a.s.} {\longrightarrow}}         % conv. a.s.
\def\conp{\stackrel{\cal P} {\longrightarrow}}        % conv. in probability
\def\conD{\stackrel{\mathcal{L}} {\longrightarrow}}        % conv. in distribution
\def\conw{\stackrel{\mathcal{L}} {\rightarrow}}        % conv. in distribution
\def\hat{\widehat}
%\def\endproof{\begin{flushright}$\lozenge$\end{flushright}}
\def\Proof{\noindent{\it Proof }}
\def\endproof{\hfill{$\Box$}}
\newcommand{\wcon}{\stackrel{\mathcal{L}}{\longrightarrow}}
\def\Var{\mbox{var}}

%%%%%%%%%%%%%%% MY DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Put your own definitions
%
\def\VaR{{\rm VaR}}
\def\E{{\rm E}}
\def\beqrs{\begin{eqnarray*}}           %\beqrs
\def\eeqrs{\end{eqnarray*}}             %\eeqrs

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\pgfdeclaremask{tu}{beamer-tu-logo-mask}
\pgfdeclaremask{computer}{beamer-computer-mask}
\pgfdeclareimage[interpolate=true,mask=computer,height=2cm]{computerimage}{beamer-computer}
\pgfdeclareimage[interpolate=true,mask=computer,height=2cm]{computerworkingimage}{beamer-computerred}
\pgfdeclareimage[mask=tu,height=.5cm]{logo}{beamer-tu-logo}

\logo{\pgfuseimage{logo}}

\title[Stat 609 Lecture 4]{Stat 609: Mathematical Statistics \\ Lecture 4}
\author[UW-Madison]{Jun Shao}
\institute[Statistics]{%
%  Department of Statistics\\
%  University of Wisconsin\\
%  Madison, WI 53706, USA\\
%~~~\\
  }
\date[2015]{}

\colorlet{redshaded}{red!25!bg}
\colorlet{shaded}{black!25!bg}
\colorlet{shadedshaded}{black!10!bg}
\colorlet{blackshaded}{black!40!bg}

\colorlet{darkred}{red!80!black}
\colorlet{darkblue}{blue!80!black}
\colorlet{darkgreen}{green!80!black}

\def\radius{0.96cm}
\def\innerradius{0.85cm}

\def\softness{0.4}
\definecolor{softred}{rgb}{1,\softness,\softness}
\definecolor{softgreen}{rgb}{\softness,1,\softness}
\definecolor{softblue}{rgb}{\softness,\softness,1}

\definecolor{softrg}{rgb}{1,1,\softness}
\definecolor{softrb}{rgb}{1,\softness,1}
\definecolor{softgb}{rgb}{\softness,1,1}

\newcommand{\Bandshaded}[2]{
  \color{shadedshaded}
  \pgfmoveto{\pgfxy(-0.5,0)}
  \pgflineto{\pgfxy(-0.6,0.1)}
  \pgflineto{\pgfxy(-0.4,0.2)}
  \pgflineto{\pgfxy(-0.6,0.3)}
  \pgflineto{\pgfxy(-0.4,0.4)}
  \pgflineto{\pgfxy(-0.5,0.5)}
  \pgflineto{\pgfxy(4,0.5)}
  \pgflineto{\pgfxy(4.1,0.4)}
  \pgflineto{\pgfxy(3.9,0.3)}
  \pgflineto{\pgfxy(4.1,0.2)}
  \pgflineto{\pgfxy(3.9,0.1)}
  \pgflineto{\pgfxy(4,0)}
  \pgfclosepath
  \pgffill

  \color{black}
  \pgfputat{\pgfxy(0,0.7)}{\pgfbox[left,base]{#1}}
  \pgfputat{\pgfxy(0,-0.1)}{\pgfbox[left,top]{#2}}
}

\newcommand{\Band}[2]{
  \color{shaded}
  \pgfmoveto{\pgfxy(-0.5,0)}
  \pgflineto{\pgfxy(-0.6,0.1)}
  \pgflineto{\pgfxy(-0.4,0.2)}
  \pgflineto{\pgfxy(-0.6,0.3)}
  \pgflineto{\pgfxy(-0.4,0.4)}
  \pgflineto{\pgfxy(-0.5,0.5)}
  \pgflineto{\pgfxy(4,0.5)}
  \pgflineto{\pgfxy(4.1,0.4)}
  \pgflineto{\pgfxy(3.9,0.3)}
  \pgflineto{\pgfxy(4.1,0.2)}
  \pgflineto{\pgfxy(3.9,0.1)}
  \pgflineto{\pgfxy(4,0)}
  \pgfclosepath
  \pgffill

  \color{black}
  \pgfputat{\pgfxy(0,0.7)}{\pgfbox[left,base]{#1}}
  \pgfputat{\pgfxy(0,-0.1)}{\pgfbox[left,top]{#2}}
}

\newcommand{\BaenderNormal}
{%
  \pgfsetlinewidth{0.4pt}
  \color{black}
  \pgfputat{\pgfxy(0,5)}{\Band{input tapes}{}}
  \pgfputat{\pgfxy(0.35,4.6)}{\pgfbox[center,base]{$\vdots$}}
  \pgfputat{\pgfxy(0,4)}{\Band{}{}}

  \pgfxyline(0,5)(0,5.5)
  \pgfxyline(1.2,5)(1.2,5.5)
  \pgfputat{\pgfxy(0.25,5.25)}{\pgfbox[left,center]{$w_1$}}

  \pgfxyline(0,4)(0,4.5)
  \pgfxyline(1.8,4)(1.8,4.5)
  \pgfputat{\pgfxy(0.25,4.25)}{\pgfbox[left,center]{$w_n$}}
  \ignorespaces}

\newcommand{\BaenderZweiNormal}
{%
  \pgfsetlinewidth{0.4pt}
  \color{black}
  \pgfputat{\pgfxy(0,5)}{\Band{Zwei Eingabebänder}{}}
  \pgfputat{\pgfxy(0,4.25)}{\Band{}{}}

  \pgfxyline(0,5)(0,5.5)
  \pgfxyline(1.2,5)(1.2,5.5)
  \pgfputat{\pgfxy(0.25,5.25)}{\pgfbox[left,center]{$u$}}

  \pgfxyline(0,4.25)(0,4.75)
  \pgfxyline(1.8,4.25)(1.8,4.75)
  \pgfputat{\pgfxy(0.25,4.5)}{\pgfbox[left,center]{$v$}}
  \ignorespaces}

\newcommand{\BaenderHell}
{%
  \pgfsetlinewidth{0.4pt}
  \color{black}
  \pgfputat{\pgfxy(0,5)}{\Bandshaded{input tapes}{}}
  \color{shaded}
  \pgfputat{\pgfxy(0.35,4.6)}{\pgfbox[center,base]{$\vdots$}}
  \pgfputat{\pgfxy(0,4)}{\Bandshaded{}{}}

  \color{blackshaded}
  \pgfxyline(0,5)(0,5.5)
  \pgfxyline(1.2,5)(1.2,5.5)
  \pgfputat{\pgfxy(0.25,5.25)}{\pgfbox[left,center]{$w_1$}}

  \pgfxyline(0,4)(0,4.5)
  \pgfxyline(1.8,4)(1.8,4.5)
  \pgfputat{\pgfxy(0.25,4.25)}{\pgfbox[left,center]{$w_n$}}
  \ignorespaces}

\newcommand{\BaenderZweiHell}
{%
  \pgfsetlinewidth{0.4pt}
  \color{black}
  \pgfputat{\pgfxy(0,5)}{\Bandshaded{Zwei Eingabebänder}{}}%
  \color{blackshaded}
  \pgfputat{\pgfxy(0,4.25)}{\Bandshaded{}{}}
  \pgfputat{\pgfxy(0.25,4.5)}{\pgfbox[left,center]{$v$}}
  \pgfputat{\pgfxy(0.25,5.25)}{\pgfbox[left,center]{$u$}}%

  \pgfxyline(0,5)(0,5.5)
  \pgfxyline(1.2,5)(1.2,5.5)

  \pgfxyline(0,4.25)(0,4.75)
  \pgfxyline(1.8,4.25)(1.8,4.75)
  \ignorespaces}

\newcommand{\Slot}[1]{%
  \begin{pgftranslate}{\pgfpoint{#1}{0pt}}%
    \pgfsetlinewidth{0.6pt}%
    \color{structure}%
    \pgfmoveto{\pgfxy(-0.1,5.5)}%
    \pgfbezier{\pgfxy(-0.1,5.55)}{\pgfxy(-0.05,5.6)}{\pgfxy(0,5.6)}%
    \pgfbezier{\pgfxy(0.05,5.6)}{\pgfxy(0.1,5.55)}{\pgfxy(0.1,5.5)}%
    \pgflineto{\pgfxy(0.1,4.0)}%
    \pgfbezier{\pgfxy(0.1,3.95)}{\pgfxy(0.05,3.9)}{\pgfxy(0,3.9)}%
    \pgfbezier{\pgfxy(-0.05,3.9)}{\pgfxy(-0.1,3.95)}{\pgfxy(-0.1,4.0)}%
    \pgfclosepath%
    \pgfstroke%
  \end{pgftranslate}\ignorespaces}

\newcommand{\SlotZwei}[1]{%
  \begin{pgftranslate}{\pgfpoint{#1}{0pt}}%
    \pgfsetlinewidth{0.6pt}%
    \color{structure}%
    \pgfmoveto{\pgfxy(-0.1,5.5)}%
    \pgfbezier{\pgfxy(-0.1,5.55)}{\pgfxy(-0.05,5.6)}{\pgfxy(0,5.6)}%
    \pgfbezier{\pgfxy(0.05,5.6)}{\pgfxy(0.1,5.55)}{\pgfxy(0.1,5.5)}%
    \pgflineto{\pgfxy(0.1,4.25)}%
    \pgfbezier{\pgfxy(0.1,4.25)}{\pgfxy(0.05,4.15)}{\pgfxy(0,4.15)}%
    \pgfbezier{\pgfxy(-0.05,4.15)}{\pgfxy(-0.1,4.2)}{\pgfxy(-0.1,4.25)}%
    \pgfclosepath%
    \pgfstroke%
  \end{pgftranslate}\ignorespaces}

\newcommand{\ClipSlot}[1]{%
  \pgfrect[clip]{\pgfrelative{\pgfxy(-0.1,0)}{\pgfpoint{#1}{4cm}}}{\pgfxy(0.2,1.5)}\ignorespaces}

\newcommand{\ClipSlotZwei}[1]{%
  \pgfrect[clip]{\pgfrelative{\pgfxy(-0.1,0)}{\pgfpoint{#1}{4.25cm}}}{\pgfxy(0.2,1.25)}\ignorespaces}


\AtBeginSection[]{\frame{\frametitle{Outline}\tableofcontents[current]}}
\def\back{\!\!\!\!\!}

\begin{document}

%\frame{\titlepage}

\frame {\vspace{-1mm}
\frametitle{Lecture 4: Expectations}
\vspace{-2mm}
\begin{block}{}
The expected value, also called the expectation or mean, of a random variable
is its average value weighted by its probability distribution.
\end{block}
\vspace{-2mm}
\begin{alertblock}{Definition 2.2.1.}
The expected value or mean of a random variable $g(X)$ is\vspace{-3mm}
\[ E[g(X)] = \left\{ \begin{array}{ll}
{\displaystyle \int_{-\infty}^\infty } g(x) f_X(x)dx & \quad \mbox{if $X$ has pdf $f_X$} \vspace{2mm}\\
{\displaystyle \sum_x } g(x) f_X(x) & \quad \mbox{if $X$ has pmf $f_X$} \end{array} \right.\vspace{-3mm} \]
provided that the integral or the sum exists (is finite); otherwise we say that the expected value of $g(X)$ does not exist.
\end{alertblock}\vspace{-2mm}
\begin{alertblock}{}
\begin{itemize}
\item
The expected value is a number that summarizes a typical, middle, or expected value of an observation of the random variable.
\item
If $g(X)\!\! \geq \!\! 0$, then $E[g(X)]$ is always defined except that it may be $\infty$.
\item
For any  $g(X)$, its expected value exists iff  $E|g(X)|<\infty$.
\item
The expectation is associated with the distribution of $X$, not with $X$. 
\end{itemize}
\end{alertblock}
}
\frame{\vspace{-2mm}
\begin{alertblock}{Example}
$X$ has distribution\\
\begin{tabular}{ccccccc} \hline
$x$ & $-2$ & $-1$ & 0 & 1 & 2 & 3 \\ \hline
$f_X(x) $ & 0.1 & 0.2 & 0.1 & 0.2 & 0.3 & 0.1 \\
\hline
\end{tabular}
\vspace{-2mm}

\[ E(X)= \sum x f_X(x) = -2 \times 0.1 - 0.2 + 0.2 + 2 \times 0.3 + 3 \times 0.1 =  0.7 \vspace{-2mm}\]
\[ E(X^2)= \sum x^2 f_X(x) = 4 \times 0.1 +  0.2 + 0.2 + 4 \times 0.3 + 9 \times 0.1 =  2.9 \]

$Y = g(X)=X^2$ has distribution \\
\begin{tabular}{ccccc} \hline
$y$ & 0 & 1 & 4 & 9 \\ \hline
$f_{Y}(y) $ & 0.1 & 0.4 & 0.4 &  0.1 \\
\hline
\end{tabular}

\[ E(Y) = E(X^2) = \sum yf_{Y}(y) = 0.4 + 4 \times 0.4 + 9 \times 0.1 = 2.9 \]
\end{alertblock}\vspace{-2mm}
\begin{block}{Example 2.2.2.}
Suppose $X \geq 0$ has pdf
$f_X(x) = \lambda^{-1} e^{-x/\lambda}$, where $\lambda >0$ is a constant. Then\vspace{-1mm}
\[ E(X) = \int_0^\infty \lambda^{-1} xe^{-x/\lambda} dx  = - xe^{-x/\lambda}\bigg|_0^\infty + \int_0^\infty e^{-x/\lambda } dx = \lambda  \]
\end{block}}
\frame{\vspace{-1mm}
\begin{alertblock}{}
In some cases, the calculation of the expectation requires some derivation.
\end{alertblock}\vspace{-2mm}
\begin{block}{Example 2.2.3.}
Let $X$ be a discrete random variable with pmf \vspace{-2mm}
\[ f_X(x) = {n \choose x} p^x (1-p)^{n-x } , \quad \quad x =0,1,...,n,\vspace{-2mm}\]
where $n$ is a fixed integer and $0<p<1$ is a fixed constant.

For any $n$ and $p$, \vspace{-2mm}
 \[ \sum_{x=0}^n {n \choose x} p^x (1-p)^{n-x }  = 1 . \vspace{-2mm}\]
By definition and the fact that $x {n \choose x}=n{n-1 \choose x-1}$, we obtain\vspace{-2mm}
\beqrs
E(X) & = & \sum_{x=0}^n x {n \choose x} p^x (1-p)^{n-x } = \sum_{x=1}^n x {n \choose x} p^x (1-p)^{n-x } \\
& = & \sum_{x=1}^n n {n-1 \choose x-1} p^x (1-p)^{n-x } =    np \sum_{y=0}^{n-1} {n-1 \choose y} p^y (1-p)^{n-1-y }\\
& = & np
\eeqrs
\end{block}
}
\frame{
\begin{block}{Example 2.2.4 (Nonexistence of  expectation)}
Suppose that $X$ has the following pdf: \vspace{-2mm}
\[ f_X(x) =
\frac{1}{\pi (1+x^2)} , \quad \quad x \in {\cal R}  \vspace{-2mm} \]
Note that \vspace{-1mm}
\beqrs
 E|X| &=& \int_{-\infty}^\infty \frac{|x|}{\pi (1+x^2)}dx = \frac{2}{\pi} \int_0^\infty \frac{x}{1+x^2}dx \\
 & = & \frac{2}{\pi} \lim_{M \rightarrow \infty} \int_0^M \frac{x}{1+x^2}dx
 =  \frac{2}{\pi} \lim_{M \rightarrow \infty} \int_0^M \frac{1}{1+x^2}d(x^2/2)\\
 & = & \frac{2}{\pi} \lim_{M \rightarrow \infty} \frac{\log (1+x^2)}{2}\bigg|_0^M  = \frac{2}{\pi} \lim_{M \rightarrow \infty} \frac{\log (1+M^2)}{2} = \infty
\eeqrs
 Thus, neither $X$ nor $|X|$ has an expectation.

 We should not wrongly think \vspace{-2mm}
 \[ E(X) =  \int_{-\infty}^\infty \frac{x}{\pi (1+x^2)}dx =  \lim_{M \rightarrow \infty}\int_{-M}^M \frac{x}{\pi (1+x^2)}dx
 = \lim_{M \rightarrow \infty} 0 = 0 \]
\end{block}
}
\frame{
\begin{block}{Linear operation}
Taking expectation is a linear operation in the sense that \\
$E(c)=c $ for any constant $c$;\\
$E(aX)=aE(X)$ for any constant $a$ and random variable $X$;\\
$E(X+Y)=E(X)+E(Y)$ for any random variables $X$ and $Y$.
\vspace{1mm}

These are special cases of the following theorem.
\end{block}\vspace{-2mm}
\begin{alertblock}{Theorem 2.2.5}
Let $X$ and $Y$ be random variables whose expectations exist, and let $a$, $b$, and $c$ be constants. \\
a. $E(aX+bY+c) = a E(X)+bE(Y)+c$.\\
b. If $X \geq Y$, then $E(X) \geq E(Y)$.
\end{alertblock}
\vspace{-2mm}
\begin{alertblock}{Proof.}
The proof of Theorem 2.2.5 is easy if $X= g_1(Z)$ and $Y = g_2(Z)$ for a random variable $Z$ and some functions $g_1$ and $g_2$,
and $Z$ has a pdf or pmf.
\vspace{1.5mm}

In general, the proof of property a is not simple (a topic in stat 709).
\end{alertblock}
}
\frame{
\begin{block}{Example 2.2.6 (Minimizing distance)}
The mean of a random variable $X$ is a good guess (predict) of $X$.\\
Suppose that we measure the distance between $X$ and a constant $b$ by
$(X-b)^2$.

The closer $b$ is to $X$, the smaller this quantity is.

We want to find a value $b$ that minimizes the average $E(X-b)^2$.

If $\mu = E(X)$, then \vspace{-2mm}
\[ E(X-\mu )^2 = \min_{b \in {\cal R}} E(X-b)^2 \]
To show this, note that
\beqrs
 E(X-b)^2 &=& E[(X-\mu)+(\mu-b))]2 \\
& = & E[(X-\mu)^2] + E[(\mu-b)^2] +E[2(X-\mu)(\mu-b)]\\
&=&  E(X-\mu)^2 + (\mu-b)^2 +2(\mu-b)E(X-\mu)\\
& = & E(X-\mu)^2 + (\mu-b)^2 \\
& \geq & E(X-\mu)^2 .
\eeqrs
There is an alternative proof using $E(X-b)^2 = E(X^2)-2bE(X)+b^2$.
\end{block}
}
\frame{\vspace{-3mm}
\begin{alertblock}{Nonlinear functions}
When calculating expectations of nonlinear functions of $X$, we can proceed in one of two ways.
\begin{itemize}
\item
Using the distribution of $X$, we can calculate \vspace{-2mm}
\[ E[g(X)] = \int_{-\infty}^\infty g(x)f_X(x)dx \quad\quad \mbox{or} \quad \quad
\sum_x g(x)f_X(x)  \vspace{-2mm}\]
\item
We can find the pdf or pmf of $Y = g(X)$, $f_Y$, and then use \vspace{-2mm}
\[ E[g(X)] = E(Y)=  \int_{-\infty}^\infty yf_Y(y)dy \quad\quad \mbox{or} \quad \quad
\sum_y y f_Y(y)  \]
\end{itemize}
\end{alertblock}\vspace{-3mm}
\begin{block}{Example 2.2.7.}
Suppose that $X$ has a uniform pdf on (0,1), \vspace{-2mm}
\[ f_X(x) = \left\{ \begin{array}{ll}
1 & \quad 0<x<1 \\
0 & \quad \mbox{otherwise} \end{array} \right. \vspace{-2mm}\]
Consider $g(X) = - \log X$. \vspace{-2mm}
\[ E[g(X)] = \int_0^1 - \log (x) dx = (x-x\log x)\bigg|_0^1 = 1 \]
\end{block}
}
\frame{ \vspace{-2mm}
\begin{block}{}
On the other hand, we can use Theorem 2.1.5 to obtain the pdf of $Y= -\log X$: \vspace{-2mm}
\[ f_Y(y) = f_X(e^{-y}) |e^{-y}| = e^{-y} , \quad y >0 \vspace{-2mm} \]
Then
\[ E[g(X)] = E(Y) = \int_{-\infty}^\infty yf_Y(y)dy =
\int_0^\infty y e^{-y} dy = 1 \]
\end{block}\vspace{-2mm}
\begin{alertblock}{Example}
Suppose that $X$ has the standard normal pdf \vspace{-2mm}
\[ f_X(x) = \frac{1}{\sqrt{2\pi} } e^{-x^2/2} , \quad x \in {\cal R}  \vspace{-2mm}\]
Consider $g(X) = X^2$.

By Example 2.1.9, $Y=X^2 $ has the chi-square pdf \vspace{-2mm}
\[  f_Y(y) = \frac{1}{\sqrt{2\pi y}} e^{-y/2}  , \quad y>0 \vspace{-2mm} \]
Then\vspace{-2mm}
\[ E(X^2)=E(Y) = \int_0^\infty yf_Y(y)dy = \frac{1}{\sqrt{2\pi}} \int_0^\infty \sqrt{y} e^{-y/2} dy = 1 \]
\end{alertblock}
}
\frame{\vspace{-2mm}
\begin{block}{Theorem}
Let $F$ be the cdf of a random variable $X$. Then \vspace{-2.5mm}
\[ E|X| = \int_0^\infty [1-F(x)]dx + \int_{-\infty}^0 F(x) dx  \vspace{-2.5mm} \]
and $E|X| < \infty$ iff both integrals are finite. In the case where $E|X| < \infty$,  \vspace{-2.5mm}
\[ E(X) = \int_0^\infty [1-F(x)]dx -  \int_{-\infty}^0 F(x) dx  \]
\end{block}\vspace{-2mm}
\begin{block}{Proof.}
We only consider the case where $X$ has a pdf or pmf, and give a proof when $X$ has a pdf (the proof for the case where $X$ has
\vspace{1.5mm} a pmf is similar).

When $X$ has a pdf $f$, \vspace{-3mm}
\[ \int_0^\infty [1-F(x)]dx = \int_0^\infty \int_x^\infty f(t) dt dx = \int_0^\infty \int_0^t f(t) dx dt =
\int_0^\infty tf(t) dt \vspace{-2mm} \]
\[ \int_0^\infty F(x)dx = \int_{-\infty}^0 \int^x_{-\infty} f(t) dt dx = \int^0_{-\infty} \int^0_t f(t) dx dt =
\int^0_{-\infty}- tf(t) dt \vspace{-2mm} \]
These calculations are valid regardless of whether the integrals are finite or not.
\end{block}}
\frame{\vspace{-2mm}
\begin{block}{}
By definition, \vspace{-2mm}
\beqrs
E|X| \back & = & \back \int_{-\infty}^\infty |t|f(t) dt = \int_0^\infty tf(t)dt + \int_{-\infty}^0 -t f(t) dt \\
\back &  = & \back
\int_0^\infty [1-F(x)]dx + \int_{-\infty}^0 F(x) dx
\eeqrs
Since both integrals $\geq 0$, $E|X| < \infty$ iff both integrals are finite.

If $E|X|  < \infty$, then both integrals are finite and \vspace{-2mm}
\beqrs
E(X) \back & = & \back \int_{-\infty}^\infty tf(t) dt = \int_0^\infty tf(t)dt + \int_{-\infty}^0 t f(t) dt \\
\back &  = & \back
\int_0^\infty [1-F(x)]dx - \int_{-\infty}^0 F(x) dx
\eeqrs
\end{block}
\vspace{-2mm}
\begin{alertblock}{Property}
For any random variable $X$, \vspace{-3mm}
\[ \sum_{n=1}^\infty P(|X| \geq n ) \leq E|X| \leq 1 + \sum_{n=1}^\infty P(|X| \geq n). \vspace{-3mm} \]
Then $E|X| < \infty$ iff the sum is finite.
\end{alertblock}}
\frame{\vspace{-2mm}
\begin{alertblock}{}
Using the previous theorem, we can prove this result regardless of whether $X$ has a pdf (pmf) or not: \vspace{-3mm}
\beqrs
E|X| \back & = & \back \int_0^\infty [1-F(x)]dx + \int_{-\infty}^0 F(x) dx  =  \int_0^\infty [1-F(x)]dx + \int_0^{\infty} F(-x) dx \\
\back & = & \back \int_0^\infty [1-F(x)+F(-x)]dx   =  \int_0^\infty [P(X > x)+P( X \leq -x)]dx  \\
\back & \leq & \back \int_0^\infty [P(X \geq x)+P( X \leq -x)]dx =\int_0^\infty P(|X| \geq x)dx \\
\back & =  & \back \sum_{n=0}^\infty  \int_n^{n+1}  P(|X| \geq x)dx
\leq \sum_{n=0}^\infty  \int_n^{n+1}  P(|X| \geq n )dx \\
\back & =  & \back \sum_{n=0}^\infty    P(|X| \geq n)
= 1 + \sum_{n=1}^\infty    P(|X| \geq n)
\eeqrs
$~~$ \vspace{-4mm}

Similarly,
\beqrs
E|X| \back & \geq & \back \int_0^\infty [P(X > x)+P( X < -x)]dx = \int_0^\infty  P(|X| > x)dx   \\
\back & = & \back     \sum_{n=0}^\infty  \int_n^{n+1}  P(|X| > x)dx \geq \sum_{n=0}^\infty    P(|X| \geq n+1 )
 =  \sum_{n=1}^\infty    P(|X| \geq n)
\eeqrs

\end{alertblock}}
\frame {
	\vspace{-2mm}
	\begin{alertblock}{Moments}
		The various moments of a random variable are an important class of expectations.
	\end{alertblock}
	\vspace{-2mm}
	\begin{block}{Definition 2.3.1.}
		\begin{itemize}
			\item
			For each positive
			integer $n$, the $n$th moment of a random variable $X$ (or $F_X$) is $E(X^n)$.
			\item
			For each positive
			integer $n$, the $n$th central moment of $X$ is $E(X-\mu)^n$, where $\mu = E(X)$.
			\item
			For each constant $p >0$, the $p$th absolute moment of $X$ is $E(|X|^p)$.
		\end{itemize}
	\end{block}
	\vspace{-2mm}
	\begin{alertblock}{Property.}
		For $p>0$ and any  random variable $X$, \vspace{-3mm}
		\[ E|X|^p < \infty \quad \mbox{iff} \quad
		\sum_{n=1}^\infty n^{p-1}  P( |X| \geq n) < \infty \vspace{-3mm} \]
		A consequence is, if the $p$th absolute moment (moment or central moment) exists and $q <p$, then the $p$th absolute moment (moment or central moment) also exists.
	\end{alertblock}
}
\frame{\vspace{-2mm}
	\begin{alertblock}{Proof.}
		From the discussion in the last lecture, \vspace{-2mm}
		\beqrs
		E|X|^p  \back & \leq & \back
		\int_0^\infty P(|X|^p \geq x) dx = p \int_0^\infty P(|X|^p \geq y^p)  y^{p-1}dy\\
		\back & = & \back  p \sum_{n=0}^\infty
		\int_n^{n+1} P(|X|^p \geq y^p)  y^{p-1}dy \leq  p \sum_{n=0}^\infty  (n+1)^{p-1} P(|X| \geq n) \\
		\back & \leq & \back p +
		2^{p-1} p \sum_{n=1}^\infty  n^{p-1} P(|X| \geq n)
		\eeqrs
		$~~$ \vspace{-4mm}
		
		where the first equality is from changing variable $x =y^p$.
		\vspace{1.5mm}
		
		Similarly, \vspace{-2mm}
		\beqrs
		E|X|^p  \back & \geq & \back
		\int_0^\infty P(|X|^p > x) dx  =   p \sum_{n=0}^\infty
		\int_n^{n+1} P(|X|^p > y^p)  y^{p-1}dy \\
		\back & \geq & \back
		p \sum_{n=0}^\infty  n^{p-1} P(|X| \geq n+1 )
		=   p \sum_{n=2}^\infty  (n-1)^{p-1} P(|X| \geq n) \\
		\back & \geq & \back
		p 2^{-p} \sum_{n=2}^\infty  n^{p-1} P(|X| \geq n)
		\eeqrs
	\end{alertblock}
}
\frame{\vspace{-2mm}
	\begin{block}{Definition 2.3.2.}
		The second central moment of a random variable $X$ is called its variance and
		denoted by ${\rm Var} (X) = E(X-\mu)^2$.
		
		The standard deviation of $X$ is
		defined as $\sqrt{{\rm Var}(X)}$.
	\end{block}\vspace{-2mm}
	\begin{alertblock}{}
		Sometime the following result is useful:\vspace{-3mm}
		\[ {\rm Var} (X) = E(X^2) - [E(X)]^2 \]
	\end{alertblock}
	\vspace{-2mm}
	\begin{block}{Measures of spread}
		\begin{itemize}
			\item
			The variance gives a measure of the degree of spread of a distribution
			around its mean (center).
			\item
			A large variance means $X$ is more variable.
			\item
			The unit on the variance is the square of the original unit.
			\item
			The standard deviation has the same qualitative interpretation as the variance, but its unit is the same as the original unit.
			\item
			If Var$(X)=0$, then $P(X = E(X))=1$.
			
			This is actually a special case of the following result:
		\end{itemize}
	\end{block}\vspace{-3mm}
	\begin{alertblock}{If $g(X) \geq 0$ and $E[g(X)]= 0$, then $P(g(X)=0)=1$.}
	\end{alertblock}
}
\frame{
	\begin{alertblock}{}
		The result can be proved in general, but we only consider the case where $X$ has a pdf or pmf.
		\vspace{1.5mm}
		
		Since $g(X) \geq 0$ and $E[g(X)]= 0$, $X$ cannot have a pdf unless $g (x) = 0$ for all $x$.
		\vspace{1.5mm}
		
		If $X$ is discrete and have positive probabilities $p_j$'s to take two  values $x_j$'s, then \vspace{-1mm}
		\[ 0 = E[g(X)] = \sum_k g(x_k) p_k \geq g(x_j) p_j \vspace{-1mm} \]
		implies that $g(x_j) = 0$ for all $j$, i.e., $P(g(X)=0)=1$.
	\end{alertblock}\vspace{-2mm}
	\begin{block}{Theorem 2.3.4.}
		If $X$ has a finite variance, then for any constants $a$ and $b$,\vspace{-2mm}
		\[ {\rm Var}(aX+b) =a^2{\rm Var}(X). \]
	\end{block}\vspace{-3mm}
	\begin{block}{Proof.}
		By definition, \vspace{-2mm}
		\beqrs
		{\rm Var}(aX+b) & = & E[(aX+b)-E(aX+b)]^2 = E[aX-aE(X)]^2 \\
		& = & a^2 E[X-E(X)]^2 = a^2 {\rm Var}(X)
		\eeqrs
	\end{block}
}
\frame{
	\begin{block}{Example 2.3.3 (the exponential distribution)}
		Suppose that $X$ has the following pdf: \vspace{-1mm}
		\[ f_X(x) = \left\{ \begin{array}{ll}
		\frac{1}{\lambda} e^{-x/\lambda}  & \quad x \geq 0 \vspace{2mm}\\
		0 & \quad x<0 \end{array} \right. \vspace{-1mm} \]
		where $\lambda >0$ is a constant.
		\[ \mu = E(X) = \int_0^\infty \frac{1}{\lambda}x e^{-x/\lambda} dx = - xe^{-x/\lambda}\bigg|_0^\infty + \int_0^\infty e^{-x/\lambda} dx
		= \lambda \vspace{-2mm} \]
		\beqrs
		{\rm Var}(X) &=& E(X-\lambda )^2 = E(X^2)-\lambda^2 =
		\int_0^\infty  \frac{x^2}{\lambda} e^{-x/\lambda } dx - \lambda^2  \\
		& = & -x^2 e^{-x/\lambda}\bigg|_0^\infty + \int_0^\infty 2x e^{-x/\lambda} dx - \lambda^2 \\
		& = & 2\lambda  \int_0^\infty \frac{1}{\lambda} xe^{-x/\lambda}dx  - \lambda^2 \\
		& = & 2 \lambda^2 - \lambda^2 = \lambda^2
		\eeqrs
	\end{block}
}
\frame{\vspace{-2mm}
	\begin{alertblock}{Example 2.3.5 (binomial distribution)}
		Suppose that $X$ is discrete with pmf \vspace{-3mm}
		\[ f_X(x) = {n \choose x} p^x(1-p)^{n-x} , \quad x=0,1,...,n, \vspace{-3mm}\]
		where $n$ is a fixed positive integer and $0<p<1$ is a fixed constant.
		
		We have obtained that $E(X) = np$.
		
		Using the identity \vspace{-2mm}
		\[ x^2 {n \choose x} = x \frac{n!}{(x-1)!(n-x)!} = xn {n-1 \choose x-1} \vspace{-2mm}\]
		we obtain \vspace{-3mm}
		\beqrs
		E(X^2) & = & \sum_{x=0}^n x^2 {n \choose x} p^x(1-p)^{n-p} = n \sum_{x=1}^n x{n-1 \choose x-1} p^x(1-p)^{n-x} \\
		& = & n p \sum_{y=0}^{n-1} (y+1) {n-1 \choose y} p^{y}(1-p)^{n-1-y} \\
		& = & np [ (n-1)p + 1] = n(n-1)p^2 + np
		\eeqrs
		$~~$ \vspace{-5mm}
		\[  {\rm Var}(X) = E(X^2)-(EX)^2 =   n(n-1)p^2 + np - (np)^2
		=n p(1-p).\]
	\end{alertblock}}

\end{document}
