% $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 8]{Stat 609: Mathematical Statistics \\ Lecture 8}
\author[UW-Madison]{Jun Shao}
\institute[Statistics]{%
%  Department of Statistics\\
%  University of Wisconsin\\
%  Madison, WI 53706, USA\\
%~~~\\
  }
\date[2014]{}

\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]}}

\begin{document}

%\frame{\titlepage}

\frame {
\frametitle{Lecture 8: Expectations}
\vspace{-2mm}
\begin{block}{}
\begin{itemize}
\item
The expected value, sometimes it is also called the expectation or mean, of a random variable
is its average value weighted according to its probability distribution.
\item
The expected value is a number that summarizes a typical, middle, or expected value of an observation of the random variable.
\end{itemize}
\end{block}
\vspace{-2mm}
\begin{alertblock}{Definition 2.2.1.}<2->
The expected value or mean of a random variable $g(X)$ is\vspace{-1mm}
\[ 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{-1mm} \]
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}{}<2->
For any  $g(X)$, its expected value exists iff  $E|g(X)|<\infty$. 
\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.}<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}<2->
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 of property a.}<3->
The proof of property a 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$. 

We give a proof in this case when $Z$ has a pdf $f_Z$.

The situation where $Z$ has a pmf can be similarly treated. 
\end{alertblock}
}
\frame{\vspace{-2mm}
\begin{alertblock}{}\vspace{-5mm}
\beqrs
E(aX+bY+c) & = & \int_{-\infty}^\infty [ag_1(z) +bg_2(z) + c] f_Z(z)dz \\
& = & a \int_{-\infty}^\infty g_1(z)  f_Z(z)dz + b\int_{-\infty}^\infty g_2(z)  f_Z(z)dz \\
&& + c \int_{-\infty}^\infty   f_Z(z)dz \\
& = & a E(X) + bE(Y) + c    
\eeqrs
In general, the proof of property a is not simple (a topic in stat 709). 
\end{alertblock}\vspace{-2mm}
\begin{alertblock}{Proof of property b.}<2->
Once property a is proved, we can easily prove property b. 

Note that $X \geq Y$ is the same as $X-Y \geq 0$. 
 
Let $Z= X-Y$ and $f_{Z}$ be the pdf of $Z$. 

Since $Z \geq 0$, $f_Z(z)= 0 $ when $z <0$. \vspace{-2mm}
\[ E(Z) = \int_{-\infty}^\infty z f_{Z}(z)dz = \int_0^\infty zf_Z(z)dz \geq 0 \vspace{-2mm}
\] 
Hence, $E(X-Y) \geq 0$.

By property a, $E(X-Y)= E(X)-E(Y) \geq 0$. 
\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.}<2->
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{
\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}{Proof of Theorem 2.1.10}<2->


\end{alertblock}
}
\end{document}
