0
$\begingroup$

Could you please guide me in the right direction for the problem below?

I don't know if I am right, but here is a headstart

Cov(X,Y) = E(XY) - E(X)E(Y) = $\int_{0}^{\infty}\int_{0}^{\infty} xy dxdy - (\int_{0}^{\infty} xf_X(x,y)dy)(\int_{0}^{\infty} yf_y(x, y)dx)$

from sympy import *
# Defining f(x, y)
fxy = E**(-x-y)
fxy

$e^{- x - y}$

# Defining E(XY)
exy = integrate(integrate(x*y, (x, 0, oo)), (y, 0, oo)) 
exy

$\infty \int_{0}^{\infty} \operatorname{sign}{\left (y \right )}\, dy$

# Defininf E(X)
ex = integrate(x*integrate(fxy, (y, 0, oo)), (x, 0, oo))
ex

$1$

# Defining E(Y)
ey = integrate(y*integrate(fxy, (x, 0, oo)), (y, 0, oo))
ey

$1$

exy - ex*ey

$-1 + \infty \int_{0}^{\infty} \operatorname{sign}{\left (y \right )}\, dy$

I am getting $\infty - (1)(1) = \infty $ as an answer.

EDIT (Answer) :

I have apparently made a mistake in writing E(XY)

Cov(X,Y) = E(XY) - E(X)E(Y) = $\int_{0}^{\infty}\int_{0}^{\infty} xy f(x, y) dxdy - (\int_{0}^{\infty} xf_X(x,y)dy)(\int_{0}^{\infty} yf_y(x, y)dx)$

exy = integrate(integrate(x*y*fxy, (x, 0, oo)), (y, 0, oo))
exy

$1$

$\endgroup$
7
  • $\begingroup$ If you do provide further indications than the definition of $\text{cov}(X,Y)$ on what is bothering you, the question is likely to get closed. $\endgroup$
    – Xi'an
    Commented Jun 4, 2018 at 20:25
  • $\begingroup$ Can you share your attempt at the problem? So we know what area on the problem you are getting stuck at. $\endgroup$
    – ZachTurn
    Commented Jun 4, 2018 at 20:42
  • $\begingroup$ I presume your + which should really be - you have done correctly, given your answer of $\infty-1$. You might want to check whether your integrand in the double integral for E(XY) is correct. $\endgroup$ Commented Jun 4, 2018 at 21:00
  • $\begingroup$ @Mark Sorry, that was a typo. I have updated the description $\endgroup$
    – piby180
    Commented Jun 4, 2018 at 21:13
  • 1
    $\begingroup$ @MarkL.Stone I can't thank you enough! It worked FINALLY $\endgroup$
    – piby180
    Commented Jun 4, 2018 at 21:35

0