% BTS exercise 1

\documentclass[11pt,a4paper]{article}
\usepackage{latexsym}

%NEW COMMANDS

\newcommand{\eqref}[1]{(\ref{#1})}
\newcommand{\mat}[1]{\mbox{\boldmath{$#1$}}}
\newcommand{\proc}[1]{$\{#1_t\}$}
\newcommand{\eps}{\varepsilon}
\newcommand{\var}{{\rm Var}}
\newcommand{\cov}{{\rm Cov}}
\newcommand{\nid}{{\rm NID}}
\newcommand{\iid}{{\rm IID}}
\newcommand{\norm}{{\rm N}}
\newcommand{\wn}{{\rm WN}}
\newcommand{\diag}{{\rm diag}}


%FORMATTING
\thispagestyle{empty}
\parindent 0pt
\parskip 11pt
\topmargin -1cm

\oddsidemargin -0.5cm
\evensidemargin -0.5cm
\textwidth 16.5cm
\textheight 23.5cm

%DOCUMENT
\begin{document}

\begin{center}
\huge ST402 Principals and Methods of Statistical Practice \\
\huge Mid-term Test: Solutions \\
\end{center}



\begin{enumerate}
%
% Qu 1
%
\item I have an urn with 3 disks of which 2 are green and 1 is
red. I toss a fair coin twice and count the number of heads; $X$
is the number of heads. I then draw $X$ disks from the urn without
replacement; $Y$ is the number of red disks that I draw.
%
   \begin{enumerate}
   \item Find $E(X)$\vspace{0.25in}

$X$ has a binomial distribution with $n=2$ and $\pi=1/2$, so
$EX=n\pi=1$.\vspace{0.25in}

and $E(Y|X)$\vspace{0.25in}

Clearly, $E[Y|X=0]=0$.
\[
E[Y|X=1]=0\times P[Y=0|X=1] +1\times P[Y=1|X=1]
\]
\[
=P[Y=1|X=1]=1/3.
\]

\[
E[Y|X=2]=0\times P[Y=0|X=2] +1\times P[Y=1|X=2]
\]

\[
=P[Y=1|X=2]=2/3.
\]
So, we can summarise as $E[Y|X]=X/3$.\vspace{0.25in}

     Hence find $E(Y)$.

\[
E[Y]=E[E[Y|X]]=E[X/3]=E[X]/3=1/3.
\]
   \item Find the probability mass function of $Y$.\vspace{0.25in}

\[
P(Y=0)=P(Y=0|X=0)P(X=0)+P(Y=0|X=1)P(X=1)+P(Y=0|X=2)P(X=2)
\]
\[
=1\times 1/4 + 2/3\times 1/2+1/3\times 1/4=2/3.
\]

\[
P(Y=1)=P(Y=1|X=1)P(X=1)+P(Y=1|X=2)P(X=2)
\]
\[
=1/3\times 1/2 +2/3\times 1/4=1/3.
\]
    \end{enumerate}
%
%
% Qu 2
%
\vspace{1cm}
\item Let $X$ and $Y$ be random variables with joint density function
\begin{equation} \label{joint:eq}
f_{X,Y}(x,y) = \left\{ \begin{array}{ll} kx, & 0 < x < y < 1, \\
0, & {\rm otherwise.} \end{array}\right.
\end{equation}
\begin{enumerate}
\item Find $k$.\vspace{0.25in}

The marginal density function of $Y$ for $0<y<1$ is
\[
f_Y(y)=\int_0^ykxdx=k[x^2/2]_0^y=ky^2/2.
\]
for other values of $y$, $f_Y(y)=0$. So, for total probability of 1,
\[
1=\int_0^1ky^2/2dy=[ky^3/6]_0^1=k/6.
\]
Hence $k=6$.
\item Write down the density of $X|Y=y$\vspace{0.25in}

the conditional density function, for $0<x<y$, and $0<y<1$, is
\[
f_{X|Y}(x|y)=\frac{f_{X,Y}(x,y)}{F_Y(y)}=6x/3y^2=2x/y^2.
\]
and for other values of $x$ that conditional density function is
zero.  For other values of $y$ it is not defined.\vspace{0.25in}

 and hence find $\var(X|Y=\frac12)$.\vspace{0.25in}

For $0<y<1$
 \[
 E[X|Y=y]=\int_0^yxf_{X|Y}(x|y)dx
 \]
 \[
 =\int_0^yx2x/y^2dx=\left[\frac{2x^3/3}{y^2}\right]_0^y=2y/3.
 \]
\[
 E[X^2|Y=y]=\int_0^yx^2f_{X|Y}(x|y)dx
 \]
 \[
 =\int_0^yx^22x/y^2dx=\left[\frac{2x^4/4}{y^2}\right]_0^y=y^2/2.
 \]
 So $\var[X|Y=y]=y^2/2-(2y/3)^2=y^2/18$, and $\var[X|Y=1/2]=1/72$
\end{enumerate}
%
\vspace{1cm}
% Qu 3
%
\item Let $Y$ and $Z$ be independent standard normal random
variables.
\begin{enumerate}
\item Show that the moment generating function of $Y$ is $M_Y(t) =
e^{t^2/2}$\vspace{0.25in}

\begin{eqnarray*}
M_Y(t)&=&\int_{-\infty}^\infty \exp(yt)\frac{1}{\sqrt{2\pi}}\exp(-y^2/2)dy\\
&=&\int{_-\infty}^\infty\frac{1}{\sqrt{2\pi}}\exp(-frac{1}{2}[(y-t)^2+t^2]dy\\
&=&\exp(t^2/2),
\end{eqnarray*}
as the integral is over the whole range of a density function for
$N(t,1)$.\vspace{0.25in}

 and hence write down the joint MGF $M_{Y,Z}(t,u)$\vspace{0.25in}

As $Y,Z$ are independent and have the same distribution,
\[
M_{Y,Z}(t,u)=M_Y(t)M_Z(u)=\exp (\frac{1}{2}(t^2+u^2)).
\]

\item Let $W=Y$ and $X= \rho Y + \sqrt{(1-\rho^2)} Z$. Derive the
joint moment generating function of $W$ and $X$.\vspace{0.25in}

\[
M_{W,X}(t,u)=E\exp [tW+uX]=E\exp [tY+u\rho Y + u\sqrt{(1-\rho^2)} Z]
\]
\[
=E\exp [Y(t+u\rho)+Zu\sqrt{(1-\rho^2)}]
\]
\[
=\exp [\frac{1}{2}[(t+u\rho)^2+(u\sqrt{(1-\rho^2)})^2]]
\]
\[
=\exp [\frac{1}{2}[t^2+2tu\rho+u^2]].
\]
\vspace{0.25in}

 Show
that $X$ is a standard normal random variable.\vspace{0.25in}

Putting $t=0$ in the above gives the MGF for $X$ as $\exp [-u^2/2]$,
which identifies it as a standard normal random variable.
\end{enumerate}
%
%
\newpage
% Qu 4
%

\item Suppose that $X_j \sim i N(0, \sigma^2_X)$  and
$Y_j \sim i N(\mu_Y, \sigma_Y^2)$ for $j=1,\dots,n$.
\begin{enumerate}
\item Find the $r^{\rm th}$ moment of $X$.\vspace{0.25in}

We have $M_X(t)=\exp (\sigma^2_Xt^2/2)$, so expanding in an
exponential series,
\[
M_X(t)= \sum_{j=0}^\infty \sigma^{2j}_Xt^{2j}/j!/2^j
\]
and the moments $\mu_r$ being the coefficients of $t^r/r!$ are given
by
\[
\mu_r=r!\sigma_X^r/(2^{r/2}(r/2)!
\]
for $r$ even, and $\mu_r=0$ for $r$ odd.
\item Find the expected value and variance of the estimator of
$\sigma_X^2$
$$
\hat{\sigma}_X^2 = \frac1n \sum_{j=1}^n X_j^2
$$
\vspace{0.25in}

We have $\hat{\sigma}_X^2$ the mean of $n$ independent and
identically distributed random variables, so
\[
E[\hat{\sigma}_X^2]=E[X_1^2]=\mu_2=\sigma_X^2.
\]
\[
\var \hat{\sigma}_X^2 = \var X_1^2/n
=(\mu_4-\mu_2^2)/n=(3\sigma_X^4-\sigma_X^4)/n=2\sigma_X^4/n.
\]
\item Find the expected value of the the estimator of $\sigma_Y^2$
$$
\hat{\sigma}_Y^2 = \frac1n \sum_{j=1}^n (Y_j - \overline{Y})^2
$$
 where $\overline{Y} = \frac1n \sum_{j=1}^m Y_j$.\vspace{0.25in}

 We can use $Y_j-\bar{Y}=W_j-\bar{W}$ where $W_j=Y_j-\mu_Y~iN(0,\sigma^2_Y)$.
 Then, $\hat{\sigma}_Y^2=\frac{1}{n}\sum_{j=1}^nW_j^2-n\bar{W}^2$,
 and
 \[
E[\hat{\sigma}_Y^2]=\sigma_Y^2-\sigma_Y^2/n=\frac{n-1}{n}\sigma_Y^2.
 \]
\end{enumerate}
\end{enumerate}
\end{document}
