# Let X and Y be random variables with joint pdf $f(x,y)=x+y$ for $0<x<1$ and $0<y<1$. Are X and Y independent? My heart says yes but my math says no.

I am using the fact that $X$ and $Y$ are independent if and only if $f_X(x)f_Y(y)=f(x,y)$. So I have

$$f_{X} (x)=\int_{0}^{1}f(x,y)dy\\=\int_{0}^{1}x+ydy\\=[xy+\frac{y^{2}}{2}]_{y=0}^{y=1}\\=x+\frac{1}{2}$$

and by basically exactly the same math, $f_Y(y)=y+\frac{1}{2}$. Then $$f_X(x)f_y(y)=(x+\frac{1}{2})(y+\frac{1}{2})=xy+\frac{1}{2}(x+y)+\frac{1}{4}\ne f(x,y)$$

And hence they are not independent. But can that be right? Why would the value of X have anything to do with the value of Y? It's not like one is a function of the other.

Or have I made a simple mistake? I looked through a couple of times and I'm pretty sure my math is right...

-
If you do the math right (not speaking about your development, but about working out the theorems and stuff), your intuition should expect independence when the function $f(x,y)$ can be written as a distribution function in $X$ times another one in $Y$, and not a "plus" instead of times. When you put a plus, things usually go wrong. If you build your intuition in those terms then your wild guess would be better expected to be false than what you did. It is very good that you did the computation though. –  Patrick Da Silva Aug 11 '12 at 23:45
@PatrickDaSilva Intuitively, would that be because when we work out the conditional distribution we can get cancellations when we have a product but not when we have a sum? –  crf Aug 12 '12 at 4:13
The best way for you to get intuition would be to work the thing out... but the reason why you must have faith is because when you read the definition of independence, it all relies on product of probabilities ; thus you expect things to screw up if you don't have products of densities in $X$ and $Y$. –  Patrick Da Silva Aug 12 '12 at 5:37
@PatrickDaSilva Which thing do you recommend I work out? Is there a particular theorem or theorems that you're referring to? –  crf Aug 12 '12 at 5:39
Specifically you should work out $$\mathbb P(X \le x, Y \le y) = \mathbb P(X \le x) \mathbb P(Y \le y) \quad \Longleftrightarrow \quad f_X(x) f_Y(y) = f(x,y).$$ If you can prove this you will probably see way better why is $x+y$ not expected to represent independent variables. The LHS is definition of independence, and the RHS is the theorem you're using to prove independence. –  Patrick Da Silva Aug 12 '12 at 6:01
show 1 more comment

Note that the conditional density f(x|y) depends on y. f(x|y)=f(x,y)/f(y).

You showed that f(y)=y+1/2 and f(x,y)=x+y. So f(x|y)=(x+y)/(y+1/2)

for any 0<=x<=1 and 0<=y<=1.

It clearly is not independent of y. So knowing y does addect the probability that X is in an fixed interval about x.

-
how about f(x,y)=xy in the interval of $\sqrt {2},\sqrt {2}$ or $1,2$? –  Seyhmus Güngören Aug 12 '12 at 0:25
It's a product, if defined on a rectangle we will have independence. –  André Nicolas Aug 12 '12 at 1:20
clear but what is the difference between product and summation then? normally product can be identified in terms of summations. –  Seyhmus Güngören Aug 12 '12 at 1:35

No mistake here. These variables are not independent.

-

X and Y are independent as you have shown. Remember that we are talking about statistical independence. A necessary and sufficient condition for statistical independence is that the joint cumulative distribution function factors as $F_{X,Y}(x,y) = F_X(x) F_Y(y)$. If the joint PDF exists, then an equivalent condition is what you have stated.

In this problem, we can still pick values of $X$ and $Y$ independently to evaluate the joint PDF or any other function of these two random variables. But $X$ and $Y$ are still statistically dependent by definition.

As a general rule: Statistical dependence $\not\implies$ functional dependence, and functional dependence $\not\implies$ statistical dependence. A famous example of the latter is the case of sample mean and variance of $N$ independent, identically distributed (IID) Gaussian random variables . The sample variance is functionally dependent on the sample mean, but they are statistically independent.

-
Yeah I get it now that you and others have explained. It boils down to $\int_{x,y:f(x,y)>0}f(x,y)dxdy$ needs to equal 1, and if I know that x=a then that restricts the values that y can take on to make that integral equal to 1. Would you say this is a good way of thinking about it? –  crf Aug 12 '12 at 4:19
You mean "X and Y are dependent", not "X and Y are independent". –  Robert Israel Aug 12 '12 at 6:40
Your right. You can also check $E[XY]=E[X]E[Y]$ for the independence condition. This may be clearer because expected values are constant. Also, independence is interpreted as that even if you know the outcome $X=x$, you cannot use that to guess $Y$: $f(Y|X)=f(Y)$. For $f(x,y)=x+y$, if you know $X=x$, you have a better idea of what $Y$ will be. For example, if $X=0.1$ or $X=0.5$, the probability of $Y=0.5$ under these two conditions are different.
No, $E[XY]=E[X]E[Y]$ does not prove independence, though $E[XY] \neq E[X]E[Y]$ does show that $X$ and $Y$ are not independent. –  Dilip Sarwate Aug 12 '12 at 3:28
No, $E[XY] = E[X]E[Y]$ proves that $X$ and $Y$ are uncorrelated, that is, their covariance is $0$ or if ypu like, the (Pearson) correlation coefficient is $0$. It does not prove that the random variables are independent. –  Dilip Sarwate Aug 12 '12 at 3:32
Okay, you are right. It is very well-known that the zero covariance doesn't mean independence, and $E[XY]=E[X]E[Y]$ essentially comea from the zero covariance because $Cov[X,Y]=E[XY]-E[X]E[Y].$ I leave my wrong answer as an example of a common mistake. –  Ikuyasu Aug 12 '12 at 3:35