# Understanding joint probability distribution function

I am new to the subject of probability and need someone to help me understand the following:

If I am given: $$f(x,y) = \begin{cases} 45xy^2(1-x)(1-y^2), & 0< x\leq 1,0< y\leq 1 \\ 0, & \text{ otherwise} \end{cases}$$

And I am asked to compute $$P(X>Y)$$

My understanding is that $$P(X>Y) = P(0< x\leq 1,0< y\leq x)$$ Based on this understanding I compute: $$45\int\limits_{0}^{1}\int\limits_{0}^{x}xy^2(1-x)(1-y^2)\, dydx$$ Now where I need help for understanding is: I will have to integrate y first as such: $$45\int\limits_{0}^{1}\left(x-x^2\right)\left(\frac{x^3}{3}-\frac{x^5}{5}\right)dx$$ And then integrate everything as a whole again? If the latter statement is correct, I would appreciate if someone could explain to me why.

Thank you!

Your understanding is correct. Note that you should write $$P(X>Y) = P(0<X\leq 1,0<Y\leq X),$$ i.e. use $X,Y$ to denote the random variables and $x,y$ to denote the variables of integration.
Strictly speaking, the probability that you need to compute is $$\int_{A}f(x,y)\,\mathrm d(x,y),$$ where $d(x,y)$ is the Lebesgue measure on $[0,1]\times[0,1]$ and $$A=\{(x,y)\in[0,1]\times[0,1]\ :\ y\le x\}.$$ Writing the double integral as you did is justified by Fubini's theorem. Since $f$ is non-negative, $$P(Y\le X)=\int_0^1\int_0^xf(x,y)\,\mathrm dy\mathrm dx=\int_0^1\int_y^1f(x,y)\,\mathrm dx\mathrm dy.$$ In other words, you may integrate in any order, the end result will be the same. You find $$P(Y\le X)=\frac{19}{56}.$$