# Finding $E[X]$ from the joint density function of $X$ and $Y$.

The joint density function of $$X$$ and $$Y$$ is given by $$f(x,y)=\frac{1}{y}e^{-(y+\frac{x}{y})},\quad x>0,y>0.$$ Find $$E[X]$$, $$E[Y]$$ and $$Cov\left(X,Y\right)$$.

Calculating $$E[Y]$$ was easy for me. \begin{align} f_{Y}(y)&=\int_{0}^{\infty} \frac{1}{y}e^{-(y+\frac{x}{y})}dx\\ &=e^{-y}, \quad y>0 \end{align} Therefore $$Y$$ is an exponential random variable with parameter $$1$$ so $$E[Y]=1$$

Now, I am stuck in calculating the density function of X. I tried to calculate it from the usual integral but I couldn't. I looked at my calculus book to revise the integrals chapter but I haven't stumble accross something like it. Any help would be much appreciated.

• You need not explicitly calculate the density function of $X$. We can also write $\displaystyle \mathbb{E}[X] = \int_{0}^{\infty} \int_{0}^{\infty} x f(x,y) \ dx \ dy$. Note that if you integrate $y$ first, then it is exactly what you were trying to do. However, in this case, you can first integrate wrt $x$ and then wrt $y$, which would be easier. – sudeep5221 May 22 at 21:51
• Can you compute: $$E[X] = \int_{0}^{+\infty} \int_{0}^{+\infty} x \frac{1}{y} e^{- \left( y + \frac{x}{y} \right)} \ dx \ dy$$ – Ertxiem May 22 at 21:51
• @sudeep5221 Oh thank you very much. that was the trick then! – billyandriam May 22 at 21:54

Thanks to @sudeep5221 for the suggestion. We do not need to explicitly calculate the density function of $$X$$.
\begin{align} E[X]&=\int_{0}^{\infty}\int_{0}^{\infty}xf(x,y)\ dx\ dy\\ &=\int_{0}^{\infty}e^{-y}\int_{0}^{\infty}\frac{x}{y}e^{-x/y}\ dx\ dy \end{align} It is noticeable that $$\int_{0}^{\infty}\frac{x}{y}e^{-x/y}\ dx$$ is the mean of an exponential random variable with parameter $$1/y$$, and thus equals to $$y$$. $$E[X]=\int_{0}^{\infty}\int_{0}^{\infty}ye^{-y}dy=1$$
To end, calculate $$Cov(X,Y)$$. $$Cov(X,Y)= E[XY]-E[X]E[Y]$$ Also \begin{align} E[XY]&=\int_{0}^{\infty}\int_{0}^{\infty}xyf(x,y)\ dx\ dy\\ &=\int_{0}^{\infty}ye^{-y}\left(\int_{0}^{\infty}\frac{x}{y}e^{-x/y}dx\right)\ dy\\ &= \int_{0}^{\infty}y^{2} e^{-y}dy \end{align} We can now integrate by parts where $$U=y^2$$ and $$dV= e^{-y}dy$$. \begin{align} E[XY]&=\int_{0}^{\infty}y^2e^{-y} dy= \left(-y^2 e^{-y}|_{0}^{\infty}\right)+\int_{0}^{\infty}2ye^{-y}dy\\ &=2E[Y]\\ &=2 \end{align} As a result, \begin{align}Cov(X,Y)&=2-(1)(1)\\ Cov(X,Y)&=1 \end{align}