Let $X, Y$ be discrete random variables taking values in the integers, with joint mass function $f$. Show that, for integers $x, y$, $$f(x,y) = P(X \ge x, Y \le y) - P(X \ge x +1, Y \le y) - P(X \ge x, Y \le y -1) + P (X \ge x+1, Y \le y-1).$$ Hence find the joint mass function of the smallest and largest numbers shown in $r$ rolls of a fair die.
Solution: The given expression equals $$P(X = x, Y \le y) - P(X = x, Y\le y-1) = P(X = x, Y=y).$$ Secondly, for $1 \le x \le y \le 6$, $f(x,y) = (\frac{y-x+1}{6})^r-2(\frac{y-x}{6})^r +(\frac{y-x-1}{6})^r$ if $x <y$, $(\frac16)^r$ if $x=y$.
First of all, I don't understand why the right hand side of the first display in the question is equal to the left hand side of the display in the solution. I guess that I need to use the previous result that $P(a<X \le b, c < Y \le d) = F(b,d) - F(a,d)- F(b,c) +F(a,c)$. Using this, I can show that the equality holds for $Y$ variable in the joint distribution, but what confuse me is $X$ variable in the joint distribution because $X \ge x$ rather than $X \le x$.
For the second part, it seems that the answer is shown, using the equality above. However, I don't clearly understand why we have such $f(x,y)$ when $x < y$.
Any help would be appreciated.
For part (1) show that $$P(X\ge x+1,Y\le y-1)-P(X\ge x+1,Y\le y)=-P(X\ge x+1,Y=y)$$ and $$P(X\ge x,Y\le y)-P(X\ge x,Y\le y-1)=P(X\ge x,Y=y).$$
For part (2) use the fact that $P(X\ge x_0,Y\le y_0)$ (where $X,Y$ denote the smallest and largest roll respectively) equals the probability of getting all the $r$ rolls in the interval $[x_0,y_0]$.