Probability uniform with transformation Given $X,Y$ being discrete random variables that are independent and can take on values $[0,1,\dots,N]$ with equal probability, what is the distribution of $\max[X,Y]=Z$?
Or any other transformation for that matter? What's the method to find something like that out?
 A: For $\max[X,Y]$, you can simply count:


*

*$\max([X,Y])=0\iff[X,Y]\in\{[0,0]\}$

*$\max([X,Y])=1\iff[X,Y]\in\{[0,1],[1,0],[1,1]\}$

*$\max([X,Y])=2\iff[X,Y]\in\{[0,2],[1,2],[2,0],[2,1],[2,2]\}$

*$\dots$

*$\max([X,Y])=N\iff[X,Y]\in\{[0,N],\dots,[N-1,N],[N,0],\dots,[N,N-1],[N,N]\}$

In other words:


*

*There are $(N+1)^2$ different combinations of $[X,Y]$

*There are $(2Z+1)$ different combinations of $[X,Y]$ such that $\max([X,Y])=Z$
Hence the probability distribution function is simply:
$$P([X,Y]=Z)=\frac{2Z+1}{(N+1)^2}$$
A: We have $\max(X,Y)\le k$ if and only if $X\le k$ and $Y\le k$.
But $\Pr(X\le k)=\Pr(Y\le k)=\frac{k+1}{N+1}$, for there are $N+1$ equally likely possibilities, of which $k+1$ are "favourable." Thus $\Pr(Z\le k)=\frac{(k+1)^2}{(N+1)^2}$.
Now
$$\Pr(X=k)=\Pr(X\le k)-\Pr(X\le k-1)=\frac{(k+1)^2}{(N+1)^2}-\frac{k^2}{(N+1)^2}.\tag{1}$$
The expression on the right of (1) can be simplified.
A: The most general method to finding the cumulative distribution function of a transformation of a (continuous) random variable $X$, say $Y = g(X)$, is by using the method of distribution functions:
$$\mathbb{P}\left(Y \leq y\right) = \mathbb{P}\left(g(X) \leq y\right) $$
and writing $\mathbb{P}\left(g(X) \leq y\right)$ in terms of $F_{X}$, the distribution function of $X$.
In this case,
$$\mathbb{P}\left(Z \leq z\right) = \mathbb{P}\left(\max[X, Y] \leq z\right)\text{.}$$
If the maximum of two random variables is $\leq z$, then BOTH random variables must be $\leq z$. Hence
$$\mathbb{P}\left(\max[X, Y] \leq z\right) = \mathbb{P}\left(X \leq z\right)\mathbb{P}\left(Y \leq z\right) = F_{X}(z)F_{Y}(z)\text{.}$$
Notice that $X$ and $Y$ are uniform and discrete with support in the nonnegative integers $\{0, 1, \dots, N\}$. 
Since $Z$ is the maximum of two random variables $\{0, 1, \dots, N\}$, $Z$ must be in $\{0, 1, \dots, N\}$ as well. Notice the following: there are $N - 0 + 1 = N+1$ integers in the support of $X$ and $Y$. So, $X$ and $Y$ equal an integer $z$ with probability $\dfrac{1}{N+1}$. To find the cumulative probability up to $z$, you find
$$\sum\limits_{k=0}^{z}\dfrac{1}{N+1} = \dfrac{1}{N+1}\sum\limits_{k=0}^{z}1 = \dfrac{1}{N+1}\underbrace{(1+1+\cdots + 1)}_{z + 1\text{ times}} = \dfrac{z+1}{N+1} = F_{X}(z)\text{.}$$
Notice, furthermore, that $X$ and $Y$ are identically distributed, so that $F_{Y} = F_{X}$. Hence
$$\mathbb{P}\left(\max[X, Y] \leq z\right) = \left(\dfrac{z+1}{N+1}\right)^{2}$$
for $z \in \{0, 1, \dots, N\}$.
So the cumulative distribution function of $Z = \max[X, Y]$ is 
$$F_{Z}(z) = \begin{cases}
0, & z < 0 \\
\left(\dfrac{z+1}{N+1}\right)^{2}, & z \in \{0, 1, \dots, N\} \\
1, & z > N\text{.}
\end{cases}$$
N.B. If you want to take into account non-integer values of $z$, use the floor function appropriately.
The probability mass function at $z$, $p_{Z}(z)$, can be derived by using
$$p_{Z}(z) = \mathbb{P}\left(Z = z\right) = F_{Z}(z) - F_{Z}(z-1) = \left(\dfrac{z+1}{N+1}\right)^{2} - \left(\dfrac{z}{N+1}\right)^{2} = \dfrac{2z+1}{(N+1)^2}$$
for $z \in \{0, 1, \dots, N\}$. Hence
$$p_{Z}(z) = \begin{cases}
\dfrac{2z+1}{(N+1)^2}, & z \in \{0, 1, \dots, N\} \\
0, & \text{otherwise.}
\end{cases}$$
