% 256f19Assignment8.tex             Conditional distributions and independence
\documentclass[11pt]{article} 
%\usepackage{amsbsy} % for \boldsymbol and \pmb 
%\usepackage{graphicx} % To include pdf files!
\usepackage{amsmath}
\usepackage{amsbsy}
\usepackage{amsfonts}
\usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=blue, urlcolor=blue]{hyperref} % For links
\usepackage{fullpage}
% \pagestyle{empty} % No page numbers

\begin{document}
%\enlargethispage*{1000 pt} 

\begin{center}   
{\Large \textbf{\href{http://www.utstat.toronto.edu/~brunner/oldclass/256f19}{STA 256f19} 
Assignment Eight}}\footnote{Copyright information is at the end of the last page.}
\vspace{1 mm}
\end{center}

\noindent
Please read Section 3.1-3.3 in the text.  Also, look over your lecture notes. The following homework problems are not to be handed in. They are preparation for Term Test 3 and the final exam. Use the formula sheet.

For some of these questions, it may not be clear whether you are supposed to use linear properties of expected value, or whether you are supposed to go back to the definition and use integration or summation. The rule is that if integration or summation is not explicitly mentioned, just use expected value signs. 

%\vspace{5mm}
\begin{enumerate} 

%%%%%%%% Expectation

\item Do Exercise 3.1.1 part (a) only.

\item Show that if $P(X \geq 0)=1$, then $E(X)\geq 0$. Treat the discrete and continuous cases separately. 

\item Let $a$ be a constant, and let $X$ be a continuous random variable, so you will integrate rather than adding. Show $E(aX) = a \, E(X)$.

\item Let $X$ and $Y$ be discrete random variables, so you will add rather than integrating. % Using the change of variables formula from the formula sheet, 
Show that $E(X+Y) = E(X) + E(Y)$. You are proving a special case of $E\left(\sum_{i=1}^n a_iX_i \right) = \sum_{i=1}^n a_iE(X_i)$ from the formula sheet, so you can't use that. If you assume independence, you get a zero.

\item Let $X$ and $Y$ be discrete random variables, so you will add rather than integrating. Prove the double expectation formula: $E(Y) = E[E(Y|X)]$. 

\item Let $X$ be a continuous random variable with $P(X \geq 0) = 1$. 
Prove $E(X) = \int_0^\infty P(X>t) \, dt$. Hint: Write the probability as an integral, sketch the region of integration, and switch order of integration using Fubini's Theorem. 

%%%%%%%% Variance

\item Show $Var(a+X) = Var(X)$.
\item Show $Var(bX) = b^2Var(X)$
\item Show $Var(X) = E(X^2)-[E(X)]^2$

\item Let $X$ have a beta distribution with parameters $\alpha$ and $\beta$. 
    \begin{enumerate}
        \item \label{betaEXk} Calculate $E(X^k)$.
        \item The Uniform(0,1) distribution is a special case of the beta distribution. What are the parameters $\alpha$ and $\beta$?
        \item Use your answer to Question \ref{betaEXk} to show that the variance of the Uniform(0,1) distribution is 1/12.
    \end{enumerate}

\item To play this casino game, you must pay an admission fee. You toss a fair coin, and wait until the first head appears. Your payoff is $2^z$ pennies, where $z$ is the number of tails that occur \emph{before} the first head. What should the admission fee be in order to make this a ``fair" game --- that is, a game with expected value zero? % St. Petersburg paradox on page 133.

\pagebreak

\item Derive the expected value formulas for the following distributions. Most of this is in the text or lecture.
    \begin{enumerate}
        \item Bernoulli ($\theta$): $E(X) = \theta$
        \item Binomial ($n,\theta$): $E(X) = n\theta$
        \item Geometric ($\theta$): $E(X) = \frac{1-\theta}{\theta}$
        \item Poisson ($\lambda$): $E(X) = \lambda$
        \item Gamma ($\alpha,\lambda$): $E(X) = \alpha/\lambda$
        \item Beta ($\alpha,\beta$): $E(X) = \frac{\alpha}{\alpha+\beta}$
    \end{enumerate}


\item \label{prodex} Let $X$ and $Y$ be independent (discrete) random variables, so you will add rather than integrating. Show $E(XY)=E(X)E(Y)$. This formula also holds for continuous random variables. 
 
\item Do Exercises 3.1.5, 3.1.7 and 3.1.9.

\item Do Exercise 3.1.11 the easy way, using independence.
\item Do Exercise 3.1.13. Use double expectation. 
\item Do Exercise 3.2.1 part (c) only.
\item Do Exercise 3.2.3 parts (a) and (f) only.
\item Do Exercise 3.2.11 the easy way. Is there any need to assume that people get married at random?



% \pagebreak

%%%%%%%% Covariance

\item Prove the following facts about covariance.
    \begin{enumerate}
        \item $Cov(X,Y) = E(XY)-E(X)E(Y)$ 
        \item If $X$ and $Y$ are independent, $Cov(X,Y)= 0$ 
        \item $Cov(a+X,b+Y) = Cov(X,Y)$ 
        \item $Cov(aX,bY)  = abCov(X,Y)$ 
        \item $Cov(X,Y+Z)  = Cov(X,Y) + Cov(X,Z)$ 
        \item $Var(aX+bY) = a^2Var(X)+b^2Var(Y) + 2abCov(X,Y)$  
    \end{enumerate}

\item \label{contxy} The continuous random variables $X$ and $Y$ have joint density function $f_{xy}(x,y)=1$ for $0<x<1$ and $2x < y < 2$, and zero otherwise. 
    \begin{enumerate}
        \item Find $cov(X,Y)$. My answer is $\frac{1}{18}$.
        \item Find $E(X|Y=y)$ My answer is $\frac{y}{4}$, defined for $0 \leq y \leq 2$.
        \item Are $X$ and $Y$ independent?
        \item Find $E(X)$ using double expectation: $E(X)=E(E[X|Y])$. Compare to the $E(X)=\frac{1}{3}$ you get using the definition of expected value. 
    \end{enumerate}

\pagebreak

\item The discrete random variables $X$ and $Y$ have joint distribution 
\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}         
    \begin{enumerate}
        \item What is $E(X|Y=1)$? [2]
        \item What is $E(Y^2|X=2)$? [13/3]
        \item What is $Cov(X,Y)$? [0]
        \item Are $X$ and $Y$ independent? Answer Yes or [No] and prove your answer.
    \end{enumerate}

\item The last question should persuade you that two random variables can have zero covariance without being independent. However, consider Exercise~2.8.10 on page 107 (an example that's surprisingly important). In that problem, $X \sim$ Bernoulli($\theta$) and $Y \sim$ Bernoulli($\psi$), and you showed that if $P(X=1,Y=1) = P(X=1)P(Y=1)$, then $X$ and $Y$ were independent --- something that is not true of random variables in general.

For that same example, show that if $Cov(X,Y)=0$, then $X$ and $Y$ are independent.

\item Let $X_1$ and $X_2$ be independent random variables; let $Y_1 = X_1 + X_2$, and  $Y_2 = X_1 - X_2$. 
    \begin{enumerate}
        \item Derive a general formula for $Cov(Y_1,Y_2)$.
        \item Give a sufficient condition for $Cov(Y_1,Y_2) = 0$.
    \end{enumerate}

\item \label{corr} The correlation between two random variables $X$ and $Y$ is defined as
\begin{displaymath}
    Corr(X,Y)  = \frac{Cov(X,Y)}{\sqrt{Var(X) \, Var(Y)}}
\end{displaymath}
Find a formula for $Corr(a+bX,c+dY)$ in terms of $Corr(X,Y)$. Assume $b$ and $d$ are both non-zero. Show your work.

\item Let the pairs $(X_1, Y_1), \ldots, (X_n,Y_n)$ be selected independently from a joint distribution with $E(X_i)=\mu_x$, $E(Y_i)=\mu_y$, $Var(X_i)=\sigma^2_x$, $Var(Y_i)=\sigma^2_y$, and $Cov(X_i,Y_i)=\sigma_{xy}$. Independence means that $X_i$ and $Y_i$ are independent of $X_j$ and $Y_j$ for $i \neq j$.

The sample mean (average) of the $X$ values is $\overline{X} = \frac{1}{n}\sum_{i=1}^nX_i$, and the sample mean of the $Y$ values is $\overline{Y} = \frac{1}{n}\sum_{i=1}^nY_i$
    \begin{enumerate}
        \item Show $Cov(X_j,\overline{X}) = \sigma^2_x/n$.
        \item Show $Cov(\overline{X},\overline{Y}) = \sigma^2_{xy}/n $
        \item Show $Corr(\overline{X},\overline{Y}) = Corr(X_i,Y_i)$.
    \end{enumerate}


\end{enumerate} % End of all the questions

% \vspace{60mm}

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

\vspace{3mm}
\hrule
\vspace{3mm}

\noindent
This assignment was prepared by  \href{http://www.utstat.toronto.edu/~brunner}{Jerry Brunner},
Department of Mathematical and Computational Sciences, University of Toronto. It is licensed under a 
\href{http://creativecommons.org/licenses/by-sa/3.0/deed.en_US}
     {Creative Commons Attribution - ShareAlike 3.0 Unported License}. Use any part of it as you like and share the result freely. The \LaTeX~source code is available from the course website: 
     
\begin{center}
\href{http://www.utstat.toronto.edu/~brunner/oldclass/256f19} {\small\texttt{http://www.utstat.toronto.edu/$^\sim$brunner/oldclass/256f19}}
\end{center}


\end{document}


\vspace{20mm} \hrule
\vspace{3mm}


\vspace{3mm} \hrule

%%%%%%%%%%%%%%%%%%%% Moment-generating functions %%%%%%%%%%%%%%%%%%%%

\item Let $X$ have a moment-generating function $M_x(t)$ and let $a$ be a constant. Show $M_{a+x}(t) = e^{at}M_x(t)$.

\item Let $X$ have a moment-generating function $M_x(t)$ and let $a$ be a constant. Show $M_{a+x}(t) = e^{at}M_x(t)$.

\item  Let $X$ and $Y$ be independent, (continuous) random variables.  Show $M_{x+y}(t) = M_x(t) \, M_y(t)$. 

\pagebreak

\item In the following table, derive the moment-generating functions (given on the formula sheet), and then use them to obtain the expected values and variances. To make the task shorter, notice that the Bernoulli is a special case of the binomial, and that the exponential and chi-squared distributions are special cases of the gamma. Do the general case first and then just write the answer for the special cases.

\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|l|c|c|c|} \hline
\textbf{Distribution} & \textbf{MGF} $M_x(t)$ & $E(X)$ & $Var(X)$ \\ \hline
Bernoulli ($p$)  &  &  & \\ \hline 
Binomial ($n,p$) &  &  & \\ \hline 
%Geometric ($p$) &  &  & \\ \hline 
Poisson ($\lambda$) &  &  & \\ \hline 
Uniform $(a,b)$ &  &  & \\ \hline 
Exponential ($\lambda$) &  &  & \\ \hline 
Gamma ($\alpha,\lambda$) &   &  & \\ \hline 
Normal ($\mu,\sigma$) &  &  & \\ \hline 
Chi-squared ($\nu$) &  &  & \\ \hline 
\end{tabular}
\renewcommand{\arraystretch}{1.0}


