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

\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 3]{Stat 609: Mathematical Statistics \\ Lecture 3}
\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]}}

\begin{document}
\def\beqrs{\begin{eqnarray*}}           %\beqrs
	\def\eeqrs{\end{eqnarray*}}             %\eeqrs

%\frame{\titlepage}

\frame {
\frametitle{
Lecture 3: Random variables, distributions, and transformations}
\vspace{-3mm}
\begin{alertblock}{Definition 1.4.1.}
A random variable $X$ is a function from $S$ into a subset of ${\cal R}$ such that
for any Borel set $B \subset {\cal R}$ $ \{X \in B \} = \{ \omega \in S: X(\omega ) \in B \}$ is an event.
\end{alertblock}
\vspace{-3mm}
\begin{alertblock}{}
\begin{itemize}
\item
It is convenient to deal with a summary variable than the elements in the original sample space.
\item
The range of a random variables is simpler than $S$.
\item
In some problems, there is a natural random variable; e.g., the number of accidents, number of successes, etc.
In other cases, we may define a random variable according to our interests.
\end{itemize}
\end{alertblock}\vspace{-3mm}
\begin{block}{Example 1.4.3. (Toss a coin 3 times)}
\begin{tabular}{ccccccccc} \hline
outcome  & hhh & hht & hth & thh & tth & tht & htt & ttt \\
$X$: number of heads  & 3 & 2 & 2 & 2 & 1 & 1 & 1 & 0 \\ \hline
\end{tabular}
\begin{itemize}
\item
The range of $X$, $\{0,1,2,3\}$, is simpler than $S$.\vspace{-1mm}
\item
$X$ treats hht, hth, thh the same, and tth, tht, htt the same.
\end{itemize}
\end{block}
}
\frame{\vspace{-1mm}
\begin{alertblock}{Induced probability}
The induced probability of $X$ is \vspace{-2mm}
\[ P_X(B) = P(X \in B ) = P(\{ \omega \in S: X(\omega ) \in B \}) \vspace{-2mm}  \]
The probability $P_X$ is called the \cred{distribution} of $X$.
\end{alertblock}\vspace{-2mm}
\begin{block}{Example 1.4.3 (continued)}
If the coin is fair, then
\begin{center}
\begin{tabular}{ccccc} \hline
$x$ & 0 & 1 & 2 & 3 \\ \hline
$P(X=x)$ & $\frac{1}{8}$ & $\frac{3}{8}$ & $\frac{3}{8}$ & $\frac{1}{8}$ \\
\hline
\end{tabular}
\end{center}
A table like this effective for $X$ taking finite many values.
\end{block}\vspace{-2mm}
\begin{alertblock}{Definition 1.5.1.}
The cumulative distribution function (cdf) of a random variable $X$, denoted by $F_X(x)$, is defined by \vspace{-2mm}
\[ F_X(x) = P_X(X \leq x ), \quad \quad x \in {\cal R} \]
\end{alertblock}
\vspace{-2mm}
\begin{block}{}
Even if $X$ may not take all real numbers, the cdf is defined for all $x \in {\cal R}$
\end{block}
}
\frame{\vspace{-2mm}
\begin{alertblock}{Example 1.4.3 (continued)}
The cdf of $X$ is a step function\vspace{-2mm}
\[ F_X(x) = \left\{ \begin{array}{ll}
0 & \quad - \infty < x < 0  \\
0.125 & \quad 0 \leq x < 1  \\
0.5 & \quad 1 \leq x < 2  \\
0.875 & \quad 2 \leq x < 3 \\
1 & \quad 3 \leq x < \infty \end{array} \right.  \]
\vspace{-7.5cm}
\begin{figure}[h]
\begin{center}
%\caption{cdf in Example 1.4.3.}
\includegraphics[height=7in, width=5in]{img1.pdf}
\end{center}
\end{figure}
\end{alertblock}
}
\frame{
\begin{block}{Theorem 1.5.3.}
The function $F(x)$ is a cdf iff\\
a. $\lim_{x \rightarrow - \infty} F(x) = 0$ and $\lim_{x \rightarrow \infty} F(x)=1$;\\
b. $F(x)$ is nondecreasing in $x$;\\
c. $F(x)$ is right-continuous: $\lim_{\epsilon \rightarrow 0, \epsilon >0} F(x+\epsilon )=F(x)$ for any $x \in {\cal R}$.
\end{block}\vspace{-2mm}
\begin{block}{}
This theorem says that
\begin{itemize}
\item
 if $F$ is the cdf of a random variable $X$, then $F$ satisfies a-c (this is easy to prove);
 \item
  if $F$ satisfies
a-c, then there exists a random variable $X$ such that the cdf of $X$ is $F$ (this is not easy to prove).
\end{itemize}
\end{block}\vspace{-2mm}
\begin{alertblock}{Definition 1.5.7.}
A random variable $X$ is continuous if $F_X(x)$ is continuous in $x$.\\
A random variable $X$ is discrete if $F_X(x)$ is a step function of $x$.
\end{alertblock}\vspace{-2mm}
\begin{alertblock}{}
There are random variables that are
neither discrete nor continuous; e.g., a mixture of the two types.
\end{alertblock}
}
\frame{\vspace{-2mm}
\begin{alertblock}{Example}
Let $c$ be a constant and \vspace{-2mm}
\[ G_c(x) = \left\{ \begin{array}{ll}
0 & \quad x < 0 \\
1-c e^{-3x} & \quad x \geq 0 \end{array} \right. \vspace{-2mm} \]
For what values of $c$, $G_c$ is a cdf?

Clearly, \vspace{-2mm}
\[ \lim_{x \rightarrow -\infty } G_c(x) = 0 , \quad \quad \lim_{x \rightarrow \infty }G_c(x) = 1 \vspace{-2mm}\]
\[ G'_c(x) = \left\{ \begin{array}{ll}
0 & \quad x < 0 \\
3c e^{-3x} & \quad x > 0 \end{array} \right. \vspace{-3mm} \]
\begin{itemize}
\item
If $c<0$, $G_c$ is decreasing.
\item
If $c >1$, $G_c(0) = 1 - c <0$.
\item
If $0 \leq c \leq 1$, then $G_c$ is nondecreasing.
\item
$G_c$ is always right-continuous.
\end{itemize}
Hence, $G_c$ is a cdf iff $0\leq c \leq 1$. \\
If $c=1$, then $G_c$ is continuous.\\
If $c=0$, then $G_c$ is a special discrete cdf. \\
If $0<c<1$, then $G_c$ is neither continuous nor discrete.
\end{alertblock}}
\frame{\vspace{-2mm}
\begin{block}{Definition 1.5.8/Theorem 1.5.10.}
Two random variables $X$ and $Y$ with cdf's $F_X$ and $F_Y$ respectively are identically distributed iff
$F_X(x)=F_Y(x)$ for any $x \in {\cal R}$, which is equivalent to
$P(X \in B)= P(Y \in B)$ for any Borel set $B$.
\end{block}
\vspace{-3mm}
\begin{alertblock}{}
Note that two identically distributed random variables are not necessarily equal (see Example 1.5.9).

The cdf's can be used to calculate various probabilities related to random variables but sometimes it is more convenient to use another function to calculate probabilities.
\end{alertblock}
\vspace{-3mm}
\begin{block}{Definition 1.6.1.}
The probability mass function (pmf) of a discrete random variable $X$ is \vspace{-2mm}
\[ f_X(x) = P(X=x)  \quad \quad x \in {\cal R} \]
\end{block}\vspace{-3mm}
\begin{alertblock}{}
\begin{itemize}
\item
For discrete $X$, $f_X(x) >0$ for only countably many $x$'s.
\vspace{-1mm}
\item
$f_X(x)$ is the size of the jump in the cdf $F_X$ at $x$.
\vspace{-1mm}
\item
For any Borel set $A$, \vspace{-2.5mm}
\[  P(X \in A) = \sum_{k \in A} f_X(k)  \quad \mbox{and} \quad  F_X(x) = P(X\leq x) = \sum_{k \leq x} f_X(k)  \vspace{-2.5mm} \]
\item
How to obtain the pmf for a discrete random variable $X$?
\end{itemize}
\end{alertblock}
}
\frame{\vspace{-2mm}
\begin{block}{How to define something similar to a pmf for a continuous $X$?}
Defining $f_X(x)=P(X=x)$ does not work for a continuous  $X$.\\
For any $\epsilon >0$, \vspace{-2.5mm}
\[ P(X=x) \leq P( x-\epsilon < X \leq x ) =F_X(x)- F_X(x-\epsilon ) \vspace{-2.5mm}\]
Since $F_X$ is continuous at $x$, we obtain   \vspace{-2mm}
\[ P(X=x) \leq \lim_{\epsilon \rightarrow 0} [F_X(x)- F_X(x-\epsilon )] = 0 \vspace{-3mm}\]
Hence, $P(X=x)=0$ for any $x \in {\cal R}$ (compare this to a discrete $X$).

For a discrete $X$, we have \vspace{-2mm}
\[ F_X(x) = \sum_{k \leq x } f_X(k) \vspace{-3mm} \]
An analog for the continuous case is to replace the sum by an integral.
\end{block}
\vspace{-2mm}
\begin{alertblock}{Definition 1.6.3.}
	The probability density function (pdf)  of a continuous random variable $X$ (if it exists) is the function $f_X(x)$ satisfying \vspace{-2mm}
	\[ F_X(x) = \int_{-\infty}^x f_X(t) dt \quad\quad x \in {\cal R} \]
\end{alertblock}}
\frame{\vspace{-2mm}
\begin{block}{}
\begin{itemize}
\item
Unlike the discrete case, a pdf of a continuous $X$ may not exist.\vspace{-0.5mm}
\item
For a continuous $X$, it is convenient to use the pdf to calculate probabilities\vspace{-0.5mm}
\item
If $F_X$ is differentiable, then $f_X(x) = F_X'(x) = \frac{d}{dx} F_X(x)$.\vspace{-0.5mm}
\item
A continuous random variable has a pdf iff its cdf is absolutely continuous.\vspace{-0.5mm}
\item
If $f$ is a pdf, the set $\{ x: f(x)>0 \}$ is called its support.
\end{itemize}
\end{block}\vspace{-2mm}
\begin{alertblock}{Theorem 1.6.5.}
A function $f(x)$ is a pdf iff \\
a. $f(x) \geq 0$ for all $x$;\\
b. $\int_{-\infty}^\infty f(x) dx = 1 $.
\end{alertblock}
\vspace{-2mm}
\begin{block}{Calculation of probabilities}
For a continuous $X$ with pdf $f_X$,  \vspace{-2mm}
\[ P(X \in A) = \int_A f_X(x)dx  \]
\end{block}
}
\frame{\vspace{-2mm}
	\begin{block}{}
For example, \vspace{-2mm}
\[ P(a<X<b)=P(a<X \leq b)=P(a\leq X<b) \vspace{-2mm}\]
\[ =P(a\leq X \leq b)= F_X(b)-F_X(a) = \int_a^b f_X(t)dt \vspace{-1mm} \]
which is the area under the curve $f_X(t)$.
\vspace{-6cm}
\begin{figure}[h]
\begin{center}
%\caption{pdf and probabilities (Example 1.6.4).}
\includegraphics[height=7in, width=4.5in]{img2.pdf}
\end{center}
\end{figure}
\end{block}
}
\frame{
\begin{alertblock}{Example (finding the cdf, given a pdf)}
Suppose that \vspace{-2mm}
\[ f_X(x) = \left\{ \begin{array}{ll}
1+x & \quad -1 \leq x < 0 \\
1-x & \quad 0 \leq x <1 \\
0 & \quad \mbox{otherwise} \end{array} \right. \vspace{-1mm} \]
$F_X(x)= ?$\\
Obviously, $F_X(x)=0$ when $x < -1$. \\
For $-1 \leq x <0$, \vspace{-1mm}
\[ F_X(x) = \int_{- \infty }^x f_X(t)dt =
\int_{-1}^x (1+t)dt = \frac{t^2}{2}+t \bigg|_{t=-1}^x = \frac{x^2}{2}+x + \frac{1}{2} \vspace{-1mm} \]
For $0\leq x <1$,  \vspace{-1mm}
\[ F_X(x) = \int_{- \infty }^x f_X(t)dt =
\int_{-1}^0  (1+t)dt + \int_0^x (1-t)dt  = \frac{1}{2} -\frac{x^2}{2} + x \vspace{-1mm} \]
For $ x \geq 1$,  \vspace{-1mm}
\[ F_X(x) = \int_{- \infty }^x f_X(t)dt =
\int_{-1}^0  (1+t)dt + \int_0^1 (1-t)dt  = \frac{1}{2} + \frac{1}{2} = 1 \]
\end{alertblock}
}
\frame{\vspace{-2mm}
\begin{alertblock}{Finding the pdf, given a cdf}
\begin{itemize}
\item
If $F_X$ is differentiable everywhere, then $f_X = F_X'$.
\item
What if $F_X$ is differentiable except for some  (at most countably many) points? \\
$f_X(x) = F_X'(x)$ for $x$ at which $F_X$ is differentiable;\\
$f_X(x) $ can be any $c \geq 0$ for $x$ at which $F_X$ is not differentiable.
\end{itemize}
\end{alertblock}\vspace{-2mm}
\begin{block}{Example}
\vspace{-1mm}
\[ F_X(x) = \left\{ \begin{array}{ll}
0 & \quad x <0 \\
x/2 & \quad 0 \leq x < 1/2 \\
x^2 & \quad 1/2 \leq x < 1 \\
1 & \quad x \geq 1 \end{array}\right. \vspace{-1mm}\]
$f_X(x) = ?$\\
$F_X$ is differentiable except at 0, 1/2 and 1. \vspace{-2mm}
\[ f_X(x) = \left\{ \begin{array}{ll}
0 & \quad x <0 \\
1/2 & \quad 0 \leq x < 1/2 \\
2x & \quad 1/2 \leq x < 1 \\
0 & \quad x \geq 1 \end{array}\right. \]
\end{block}
}
\frame{\vspace{-2mm}
\begin{alertblock}{Example.}
What values of $\theta$ and $\beta$ will make $f(x)$ a pdf?
\vspace{-2mm}
\[ f(x) = \beta e^{\theta x - |x| } \quad\quad x \in {\cal R} \vspace{-2mm} \]
If $\theta \geq 1$, then $\lim_{x \rightarrow \infty} e^{\theta x - |x| } = \infty$; if
 $\theta \leq -1$, then $\lim_{x \rightarrow - \infty} e^{\theta x - |x| } = \infty$; hence,
 $\theta$ has to be in $(-1, 1)$.
 \vspace{1mm}

For $\theta \in (-1,1)$, \vspace{-2mm}
\[ \int_{-\infty}^\infty e^{\theta x - |x| } dx = \int_{-\infty}^0 e^{\theta x +x }dx + \int_0^\infty e^{\theta x -x}dx
= \frac{1}{1+\theta} + \frac{1}{1-\theta } = \frac{2}{1-\theta^2} \vspace{-2mm} \]
Hence, in orde to have a pdf, we must have $ \beta = (1-\theta^2)/2$.
\vspace{1mm}

What is the cdf of $f$?

For $x \leq 0$, \vspace{-2mm}
\[ F(x) = \int_{-\infty}^xf(t)dt = \frac{1-\theta^2}{2} \int_{-\infty}^x e^{\theta t+t}dt = \frac{1-\theta}{2} e^{(1+\theta )x} \vspace{-2mm} \]
For $x >0$, \vspace{-2mm}
\[ F(x) = \int_{-\infty}^xf(t)dt = \frac{1-\theta^2}{2} \left[ \int_{-\infty}^0 e^{\theta t+t}dt
+ \int_0^x e^{\theta t - t}dt \right] = 1 - \frac{1+\theta}{2} e^{(1-\theta )x} \]
\end{alertblock}}
\frame {
	\vspace{-2mm}
	\begin{block}{Transformations}
		For a random variable $X$, we are often interested in a transformation,
		$Y= g(X)$, which is also a random variable.\\
		Here $g$ is a function from the space for $X$ to a new space.\\
		For an event $A$ in the $Y$-space,
		\[ P(Y \in A) = P(g(X)\in A ) = P(X \in g^{-1}(A) )\]
		where
		\[ g^{-1}(A) = \{ x: g(x) \in A \} . \]
		Here, $g^{-1}$ is not the inverse function and $g^{-1}(A)$ is an event.
	\end{block}
	\vspace{-2mm}
	\begin{alertblock}{Example: $g(x)=x^2$}
		If $A= \{ t \}$, a single point with $t \geq 0$, then $g^{-1}(\{t\}) = \{ -\sqrt{t}, \sqrt{t} \}$,
		since $g(-\sqrt{t})=(-\sqrt{t})^2 = t$ and
		$g(\sqrt{t})=(\sqrt{t})^2 = t$.\\
		If
		$A = [a,b]$ with $0 \leq a \leq b$, then
		$g^{-1}(A) = [-\sqrt{b},-\sqrt{a}] \cup [\sqrt{a},\sqrt{b}]$.
	\end{alertblock}
}
\frame{
	\begin{block}{How to obtain $F_Y$ (or $f_Y$) using $F_X$ (or $f_X$)?}
		If $X$ is discrete, then $Y$ is also discrete.\\
		The pmf for $Y$ is \vspace{-1mm}
		\[ f_Y(y) = P(Y=y) = P(g(X)=y)\]
		\[= \sum_{x: \ g(x) = y} P(X=x) = \sum_{x: \ x \in g^{-1}(\{y\})}f_X(x).\]
		For discrete $X$, we often can directly work out a formula for
		$f_Y$.
	\end{block}\vspace{-2mm}
	\begin{alertblock}{Example}
		Suppose $X$ has the following 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{1mm}
		
		Let $Y = X^2$.
		
		Then $Y$ can take values 0, 1, 4, and 9 and the distribution of $Y$ is\\
		\begin{tabular}{ccccc} \hline
			$y$ & 0 & 1 & 4 & 9 \\ \hline
			$f_Y(y) $ & 0.1 & 0.4 & 0.4 &  0.1 \\
			\hline
		\end{tabular}
	\end{alertblock}
}
\frame{\vspace{-1mm}
	\begin{alertblock}{Continuous random variables}
		If $X$ is continuous with a pdf $f_X$, then \vspace{-1mm}
		\[ F_Y(y) = P( Y \leq y )
		=  P(g(X) \leq y )
		=  \int_{\{x: \ g(x) \leq y\}} f_X(x)dx \vspace{-1mm}\]
		In general, the region $\{ x: g(x) \leq y \}$ may be difficult to identify.
		
		Sometimes it is possible to find simple formulas for the cdf and pdf of $Y$ in terms of the cdf and pdf of $X$.
	\end{alertblock}\vspace{-2mm}
	\begin{block}{Example: $Y = X^2$}
		If $y \leq 0$, $F_Y(y)=0$ and $f_Y(y)=0$.\\
		If  $y >0$,\vspace{-2mm}
		\beqrs
		F_Y(y) &=& \int_{\{x: \ x^2 \leq y\}} f_X(x)dx = \int_{\{x:\ -\sqrt{y}\leq x \leq \sqrt{y}\}} f_X(x)dx \\
		&=&\int_{ -\sqrt{y}}^{ \sqrt{y}} f_X(x)dx  = F_X(\sqrt{y}) - F_X(-\sqrt{y}) \\
		f_Y(y) &= &\frac{d}{dy} F_Y(y) = f_X(\sqrt{y}) \frac{1}{2 \sqrt{y}}
		+f_X(- \sqrt{y}) \frac{1}{2 \sqrt{y}}
		\eeqrs
	\end{block}
}

\frame{\vspace{-3mm}
	\begin{block}{}
		If $g$ is strictly monotone, then the inverse function $g^{-1}$ exists and\vspace{-2mm}
		\[ \{ x: g(x) \leq y \} = \left\{ \begin{array}{ll}
		\{ x: x \leq g^{-1}(y) \} & \quad \mbox{if $g$ is increasing} \vspace{1mm}\\
		\{ x: x \geq g^{-1}(y) \} & \quad \mbox{if $g$ is decreasing} \end{array} \right. \]
	\end{block}\vspace{-3mm}
	\begin{alertblock}{Theorem 2.1.3/Theorem 2.1.5}
		Let $X$ be a continuous random variable and  $Y = g(X)$ with range ${\cal Y}$. \\
		a. If $g$ is increasing, then $F_Y(y) = F_X(g^{-1}(y))$, $y \in {\cal Y}$.\\
		b. If $g$ is decreasing, then $F_Y(y) = 1-F_X(g^{-1}(y))$, $y \in {\cal Y}$.\\
		c. If $f_X$ is continuous and $g$ is continuously differentiable,  then \vspace{-3mm}
		\[ f_Y(y) = \left\{ \begin{array}{ll}
		f_X(g^{-1}(y)) \big| \frac{d}{dy} g^{-1}(y) \big| & \quad y \in {\cal Y} \vspace{1mm} \\
		0 & \quad \mbox{otherwise} \end{array} \right. \]
	\end{alertblock}
	\vspace{-3mm}
	\begin{block}{Example 2.1.5.}
		Suppose that $Y = g(X) $, $g(x)=1/x$,  and $X$ has the pdf \vspace{-2mm}
		\[ f_X(x) = [(n-1)! \beta^n ]^{-1} x^{n-1} e^{-x/\beta } , \quad x>0  \vspace{-2mm}\]
		Then ${\cal Y} = (0,\infty )$, $g^{-1} (y) = 1/y$, $\frac{d}{dy}g^{-1}(y) = -1/y^2$, and \vspace{-2mm}
		\[ f_Y(y) = f_X(g^{-1}(y)) \big| -1/y^2\big| = [(n-1)! \beta^n]^{-1} y^{-(n+1)} e^{-1/(\beta y)}, \quad y >0 \]
	\end{block}
}
\frame{
	\begin{alertblock}{}
		Many useful functions are not monotone.
		
		The next theorem extends Theorem 2.1.5 to the case where $g$ is piecewise monotone.
	\end{alertblock}\vspace{-2mm}
	\begin{block}{Theorem 2.1.8.} 
		Let $X$ be a continuous random variable with pdf $f_X$.
		Suppose that there are disjoint $A_1$,...,$A_k$ such that
		$P( X \in \cup_{t=0}^k A_t ) =1$,
		$f_X$ is continuous on each $A_t$, $t=1,...,k$,
		and there are functions $g_1(x)$,...,$g_k(x)$ defined on $A_1$,...,$A_k$,
		respectively, satisfying \\
		i. $g(x) = g_t(x)$ for $x \in A_t$;\\
		ii. $g_t(x)$ is strictly monotone on $A_t$;\\
		iii. the set ${\cal Y} = \{ y: y=g_t(x)$ for some $x \in A_t\}$ is the same for each $t$;\\
		iv. $g_t^{-1}(y)$ has a continuous derivative on ${\cal Y}$ for each $t$.\\
		Then $Y$ has the pdf \vspace{-3mm}
		\[ f_Y(y) = \left\{ \begin{array}{ll}
		{\displaystyle \sum_{t=1}^k } f_X(g_t^{-1}(y)) \left| \frac{d}{dy} g_t^{-1}(y) \right| & \quad y \in {\cal Y} \vspace{2mm} \\
		0 & \quad \mbox{otherwise} \end{array} \right. \]
	\end{block}
}
\frame{\vspace{-2mm}
	\begin{alertblock}{Example 2.1.9 ($Y = X^2$)}
		Let $A_1= (-\infty , 0)$, $A_2 = (0,\infty )$, ${\cal Y} = (0,\infty )$. \\
		On $A_1$, $g_1(x) = x^2$ is decreasing, $g_1^{-1}(y) = -\sqrt{y}$;\\
		On $A_2$, $g_2(x) = x^2$ is increasing, $g_2^{-1}(y) = \sqrt{y}$.\\
		By Theorem 2.1.8, \vspace{-1mm}
		\[  f_Y(y)=
		f_X(-\sqrt{y}) \left| - \frac{1}{2\sqrt{y}} \right| +f_X(\sqrt{y}) \left| \frac{1}{2\sqrt{y}} \right|
		\quad y >0 \vspace{-1mm}  \]
		We obtained this previously.
		\vspace{1mm}
		
		As a special case, consider\vspace{-1mm}
		\[ f_X(x) = \frac{1}{\sqrt{2\pi} } e^{-x^2/2} , \quad x \in {\cal R} \quad \mbox{(the standard normal)} \vspace{-1mm}\]
		Then, for $y >0$,\vspace{-1mm}
		\[  f_Y(y) =
		\frac{1}{\sqrt{2\pi} } e^{-(-\sqrt{y})^2/2} \bigg| - \frac{1}{2\sqrt{y}} \bigg| +
		\frac{1}{\sqrt{2\pi} } e^{-(\sqrt{y})^2/2}  \bigg| \frac{1}{2\sqrt{y}} \bigg|  = \frac{1}{\sqrt{2\pi y}} e^{-y/2} , \vspace{-1mm} \]
		which is the chi-square pdf with 1 degree of freedom.
		
	\end{alertblock}
}

\end{document}
