% \documentclass[serif]{beamer} % Serif for Computer Modern math font.
\documentclass[serif, handout]{beamer} % Handout to ignore pause statements.
\hypersetup{colorlinks,linkcolor=,urlcolor=red}
\usefonttheme{serif} % Looks like Computer Modern for non-math text -- nice!
\setbeamertemplate{navigation symbols}{} % Suppress navigation symbols
% \usetheme{Berlin} % Displays sections on top
\usetheme{Frankfurt} % Displays section titles on top: Fairly thin but still swallows some material at bottom of crowded slides
%\usetheme{Berkeley}
\usepackage[english]{babel}
\usepackage{amsmath} % for binom
\usepackage{amsfonts} % for \mathbb{R} The set of reals
% \usepackage{graphicx} % To include pdf files!
% \definecolor{links}{HTML}{2A1B81}
% \definecolor{links}{red}
\setbeamertemplate{footline}[frame number]
\mode
\title{Joint Distributions: Part One\footnote{ This slide show is an open-source document. See last slide for copyright information.} \\ Section 2.7}
\subtitle{STA 256: Fall 2019}
\date{} % To suppress date
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Overview}
\tableofcontents
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Joint Distributions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Joint Distributions: The idea} \pause
%\framesubtitle{}
\begin{itemize}
\item A single random variable is a measurement conducted on the elements of the sample space.
\item More than one measurement can be taken on the same $s \in S$.
\item For example, $X$ is height, and $Y$ is weight.\pause
\item Of course more than two measurements are possible.
\item Most real data sets have dozens of measurements on each sampling unit. \pause
\item Technically, a pair of jointly distributed random variables is a function from $S$ to $\mathbb{R}^2$.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Probability}
%\framesubtitle{}
As with single random variables, the joint probability distribution of a set of random variables comes from the underlying probability distribution defined on the subsets of $S$. \pause
{\Large
\begin{displaymath}
P\left( (X,Y) \in C \right)
= P\left\{s \in S: (X(s),Y(s)) \in C \right\}
\end{displaymath}
} % End size
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Joint Cumulative Distribution Functions}
Whether $X$ and $Y$ are discrete or continuous, their joint distribution is defined by \pause
%\framesubtitle{}
{\LARGE
\begin{displaymath}
F(x,y) = P\{X \leq x, Y \leq y \}
\end{displaymath}
} % End size
\end{frame}
% Q Ask for prob in a rectangular region based on joint cdf
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Discrete Distributions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Joint Probability Function}
\framesubtitle{Probability Mass Function}
{\LARGE
\begin{displaymath}
p(x,y) = P(X=x,Y=y)
\end{displaymath}
} % End size
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Example}
%\framesubtitle{}
The discrete random variables $X$ and $Y$ have joint distribution \pause
\begin{center}
\begin{tabular}{c|ccc}
& $x=1$ & $x=2$ & $x=3$ \\ \hline
$y=1$ & $3/12$ & $1/12$ & $3/12$ \\
$y=2$ & $1/12$ & $3/12$ & $1/12$ \\
\end{tabular}
\end{center} \pause
\begin{itemize}
\item What is $P(Y=1)$? \pause $p_{_Y}(1) = \frac{3}{12} + \frac{1}{12} +\frac{3}{12} = \frac{7}{12}$ \pause
\item What is $P(Y=2)$? \pause $p_{_Y}(2) = \frac{1}{12} + \frac{3}{12} +\frac{1}{12} = \frac{5}{12}$ \pause
\item What is $P(X=2)$? \pause $p_{_X}(2) = \frac{1}{12} + \frac{3}{12} = \frac{4}{12}$
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Marginal distributions}
%\framesubtitle{}
\begin{center}
\begin{tabular}{c|ccc||c}
& $x=1$ & $x=2$ & $x=3$ & {\color{red} $p_{_Y}(y)$} \\ \hline
$y=1$ & $3/12$ & $1/12$ & $3/12$ & {\color{red} $7/12$} \\
$y=2$ & $1/12$ & $3/12$ & $1/12$ & {\color{red} $5/12$} \\ \hline \hline
{\color{blue}$p_{_X}(x)$} & {\color{blue}$4/12$} & {\color{blue}$4/12$}
& {\color{blue}$4/12$} & 1.00
\end{tabular}
\end{center} \pause
Give the marginal distribution of $Y$. \pause
\begin{displaymath}
p_{_Y}(y) = \left\{ \begin{array}{ll} % ll means left left
\frac{7}{12} & \mbox{for $y=1$} \\
& \\
\frac{5}{12} & \mbox{for $y=2$} \\
& \\
0 & \mbox{Otherwise}
\end{array} \right. % Need that crazy invisible right period!
\end{displaymath} \pause
Notation: $p_{_{X,Y}}(1,2) = 1/12$
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{In general}
%\framesubtitle{}
\begin{itemize}
\item $p_{_X}(x) = \sum_y p_{_{X,Y}}(x,y)$ \pause
\item $p_{_Y}(y) = \sum_x p_{_{X,Y}}(x,y)$ \pause
\item Two-dimensional, three-dimensional marginals etc.~are obtained by summing over the other variables. \pause
\item Implicitly, the summation is over values where the joint probability is non-zero. \pause
\end{itemize} \vspace{3mm}
\begin{displaymath}
p_{_X}(x) = \sum_{\{y:\,p(x,y)>0\}} p(x,y)
\end{displaymath}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Multinomial Distribution}
\framesubtitle{Begin with an example} \pause
\begin{itemize}
\item A six-sided die is rolled $n$ times. \pause
\item The die is not necessarily fair. \pause
\item Probabilities are $\theta_j$ for $j=1, \ldots, 6$. \pause
\item Want probability of $n_1$ ones, \ldots, $n_6$ sixes. \pause
\item The probability of any particular string is \pause
$\theta_1^{n_1} \, \theta_2^{n_2} \, \theta_3^{n_3} \,
\theta_4^{n_4} \, \theta_5^{n_5} \, \theta_6^{n_6}$ . \pause
\item How many ways are there to choose $n_1$ positions for the ones, $n_2$ positions for the twos, etc.? \pause
\item $\binom{n}{n_1~\cdots~n_6} = \frac{n!}{n_1!~\cdots~n_6!}$\pause, so \pause
\end{itemize}
\begin{displaymath}
P(X_1=n_1, X_2=n_2, \ldots, X_6 = n_6) = \binom{n}{n_1~\cdots~n_6} \theta_1^{n_1} \cdots \theta_6^{n_6}
\end{displaymath}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Multinomial Distribution in General} \pause
%\framesubtitle{Begin with an example}
\begin{displaymath}
p(n_1, \ldots, n_r) =
\left\{ \begin{array}{cl} % ll means left left
\binom{n}{n_1~\cdots~n_r} \theta_1^{n_1} \cdots \theta_r^{n_r}
& \mbox{for $(n_1, \ldots, n_r) \in A$} \\
& \\
0 & \mbox{Otherwise}
\end{array} \right. % Need that crazy invisible right period!
\end{displaymath} \pause \vspace{5mm}
where $(n_1, \ldots, n_r) \in A$ means \pause
\begin{itemize}
\item[] $n_j \geq 0$ for $j=1, \ldots,r$ and \pause
\item[] $\sum_{j=1}^r n_j = n$. \pause
\end{itemize} \vspace{2mm}
If we count the number of people (in a random sample) in $r$ different occupational categories, the multinomial is a reasonable model for the counts.
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Continuous Distributions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Continuous Jointly Distributed Random Variables} \pause
%\framesubtitle{}
\begin{itemize}
\item Joint density of $(X,Y)$ is not a curve, but a surface. \pause
\includegraphics[width=1.75in]{BivariateNormal} \pause
\item Probability is volume rather than area. \pause
\item This is multivariable calculus. \pause
\item We need a quick lesson.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Partial Derivatives} \pause
%\framesubtitle{}
\begin{center}
\includegraphics[width=1.6in]{JointCDF}
\end{center} \pause
{\small
\begin{itemize}
\item Think of holding $x$ fixed at some value, disregarding all other points. \pause
\item Literally slice the surface with a plane at $x$. \pause
\item The cut mark on the surface is a function of $y$. \pause
\item It's just $F(x,y)$ treating $x$ as a fixed constant. \pause
\item You can differentiate that function.
\end{itemize}
} % End size
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Vocabulary: ``Partial derivatives"} \pause
%\framesubtitle{}
\begin{itemize}
\item Consider a function of several variables, like $g(x_1,x_2,x_3)$. \pause
\item Differentiate with respect to one of the variables, treating the others as fixed constants. \pause
\item Call the result a \emph{partial derivative}.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Notation for partial derivatives} \pause
%\framesubtitle{}
\begin{itemize}
\item $\frac{\partial}{\partial x_2} g(x_1,x_2,x_3)$ \pause or $\frac{\partial f}{\partial x_2}$ \pause means differentiate $g(x_1,x_2,x_3)$ with respect to $x_2$, holding $x_1$ and $x_3$ constant. \pause
\item $\frac{\partial^2}{\partial x_1\partial x_2} g(x_1,x_2,x_3)$ \pause or $\frac{\partial^2 f}{\partial x_1\partial x_2}$ \pause means first differentiate with respect to $x_2$ holding $x_1$ and $x_3$ constant\pause, and then differentiate the result with respect to $x_1$, holding $x_2$ and $x_3$ constant. \pause
\item When the derivatives are continuous functions, order of partial differentiation does not matter. \pause
\item $\frac{\partial^2}{\partial x_1^2} g(x_1,x_2,x_3)$ \pause or $\frac{\partial^2 f}{\partial x_1^2}$ \pause means differentiate twice with respect to $x_1$, holding $x_2$ and $x_3$ constant.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Example: $g(x_1,x_2) = x_1^2e^{7x_2}$} \pause
%\framesubtitle{}
%{\LARGE
\begin{eqnarray*}
\frac{\partial g}{\partial{x_1}}
& = & \pause 2x_1e^{7x_2} \\ \pause
\frac{\partial^2 g}{\partial x_1\partial x_2}
& = & \frac{\partial}{\partial{x_1}} x_1^2 7e^{7x_2} \\ \pause
& = & 14 x_1 e^{7x_2} \\ \pause
\frac{\partial^2 g}{\partial x_2^2}
& = & \frac{\partial}{\partial{x_2}} x_1^2 7e^{7x_2} \\ \pause
& = & 7 x_1^2 \frac{\partial}{\partial{x_2}}e^{7x_2} \\ \pause
& = & 49 x_1^2 e^{7x_2}
\end{eqnarray*}
%} % End size
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Multiple integration} \pause
%\framesubtitle{}
$\displaystyle \int\int_A f(x,y) \, dx \, dy$ is the volume under the surface $f(x,y)$, over the region $A$ in the $x,y$ plane. \pause \vspace{3mm}
\begin{displaymath}
\int_a^b \int_c^d f(x,y) \, dx \, dy \pause
= \int_a^b \left(\int_c^d f(x,y) \, dx \right) \, dy
\end{displaymath} \pause
Recipe:
\begin{itemize}
\item Do the inner integral first, integrating from $c$ to $d$, and treating $y$ as a fixed constant. \pause
\item Then integrate the resulting function of $y$, from $a$ to $b$. \pause
\item This yields volume under the surface $f(x,y)$, sitting over the region defined by $c < x < d$ and $a < y < b$.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Multiple integration can be pretty mechanical}
\framesubtitle{$\displaystyle \int_a^b \left(\int_c^d f(x,y) \, dx \right) \, dy$} \pause
\begin{itemize}
\item Do the innermost integral first and work your way out, treating the other variables as constants at each step. \pause
\item If you are integrating over finite intervals, switch order of integration freely. \pause
\item If the quantity being integrated is non-negative, you may switch order of integration and the result is the same, even if the answer is ``infinity." \pause Thank you, Mr. Fubini. \pause
\item[]
\item There is one thing you often need to watch out for.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Region of integration}
\framesubtitle{$\displaystyle \int_a^b \left(\int_c^d f(x,y) \, dx \right) \, dy$} \pause
\begin{itemize}
\item If the function $f(x,y)$ is a case function that is zero for some values of $x$ and $y$, you need to take care that you are integrating over the correct region. \pause
\item You may need to sketch the region of integration.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Example}
%\framesubtitle{}
{\LARGE
\begin{displaymath}
f(x,y) =
\left\{ \begin{array}{ll} % ll means left left
x y^2 & \mbox{for } x < y \\
0 & \mbox{elsewhere}
\end{array} \right.
\end{displaymath} \pause
} % End size
Find $\displaystyle \int_{0}^{1} \int_{0}^{1} f(x,y)\,dy\,dx $. \pause \vspace{5mm}
$\displaystyle \int_{0}^{1} \int_{0}^{1} xy^2\,dy\,dx = \frac{1}{6}$\pause , but that's not the right answer. \pause \vspace{5mm}
$f(x,y)$ only equals $xy^2$ for $x