Distribution of $\sum_{i=1}^n \max\{(r-X_i),0\}$, with $X_i$ continuous positive iid

Let $X^{(r)} = \sum_{i=1}^n\max\{(r-X_i),0\}$ with $X_i$ a sequence of i.i.d., positive, continuous random variables with CDF $F$ and PDF $f$. We want to understand the distribution $X^{(r)}$. Suppose first that $n=1$ thus $X^{(r)} = \max\{(r-X),0\}$, then we find: $$ f_{X^{(r)}}(x) = \begin{cases} 0 & \mbox{ if } x < 0\\ f(r-x) & \mbox{ if } 0 \leq x \leq r\\ 0 & \mbox{ if } r < x, \end{cases} $$ while $\mathbb{P}\{X^{(r)}=0\} = 1-F(r)$. Now I wonder if we can generalize this to $n > 1$ in particular $n=2$.


$\require{begingroup}\begingroup\newcommand{\ind}[1]{{\mathcal{I}}_{#1}}$Disclaimer: Please see the comments below this answer post. I misread the question statement as $X^{(r)}=\max\{r-X_1,\, r-X_2,\, \ldots, r-X_n, 0\}$. Nonetheless, the OP found it still of some value, therefore I have not deleted it.

Recap and Setup

First, a recap of $n = 1$ to establish something that will be useful later. As stated in the question, the density for $T \equiv \max\{ r - X, 0\}$ is $$f_T(t) = \begin{cases} 0 &,~~ t < 0\\ \text{atom} &,~~ t = 0~~, \quad \small\text{where the atom is a point mass}~~ 1 - F_X(r)\\ f_X(r-t) &,~~ 0< t \leq r \\ 0 &,~~ t>r \end{cases} \tag{0} \label{Eq_density_of_n=1}$$

An alternative expression that will come in handy is $$f_T(t) = f_X(r-t)\ind{0 < t \leq r} + \bigl( 1 - F_X(r) \bigr) \delta(t) \tag{1} \label{Eq_delta_ind_example}$$ where $\delta(t)$ is the Dirac delta function, and $\ind{\text{statement}}$ is the indicator function that is zero everywhere except when the statement is true, where it takes the value of $1$.

The more compact Eq.\eqref{Eq_delta_ind_example} is a legitimate density function, and one can do variable transformation like $T' \equiv g(T)$ as usual when $g$ is invertible. Namely, with the inverse mapping $T = h(T')$ as $h \equiv g^{-1}$ we have (using a dummy $x$)

$$f_{T'}(x) = \left| \mathcal{J}\right| f_T\bigl( h(x) \bigr) \ind{0 < h(x) \leq r} + \bigl( 1 - F_T(r) \bigr)\delta\bigl( h(x) \bigr) \tag{2} \label{Eq_transformation_example}$$

where $\mathcal{J}$ is the Jacobian. Note that the atom contribution remains unchanged "because" the amplitude $\bigl( 1 - F_T(r) \bigr)$ doesn't explicitly involve $x$.
(While indeed $\delta\bigl( h(x) \bigr)$ is shifted but its magnitude is unaffected due to how the Dirac delta is defined as a functional and not an ordinary function.)

What We Already Know Without Calculation

Obviously, the density for $X^{(r)} = \max\{ r - X_1, r - X_2, 0\}$ is going to be zero on the negative half, due to taking max with $0$. At the same time, given $X_1 \ge 0$ and $X_2 \ge 0$, we know that $X^{(r)}$ cannot be greater than $r$.

That is, one can reasonably anticipate a structure similar to or the same as Eq.\eqref{Eq_density_of_n=1}

$$f_{ X^{ (r) } }(x) = \begin{cases} 0 &,~~ x < 0\\ \text{atom of some magnitude} &,~~ x = 0~~\text{maybe here or somewhere else}\\ \text{some density} &,~~ 0< x \leq r\\ 0 &,~~ x>r \end{cases}$$

Derive $n = 2$ Algebraically

Allow me to change the notations and widen the scope a bit to make some details clearer. The objective is to find the density of$$Z \equiv \min\{ r-X, r-Y, 0\}$$ where $X \ge 0$ and $Y \ge 0$ are independent but not necessarily identical with given densities $f_X$ and $f_Y$.

Note that max respects an overall shift, and since $\{X,Y,r\}$ are non-negative we can flip it to min. \begin{align*} -r + \max\{ r - X, r- Y, 0 \} = \max\{ -X, -Y, -r \} &= -\min\{ X, Y, r \} \\ &= -\min\bigl\{ \min\{ X, Y \}, r \bigr\} \end{align*} Therefore, we can breakdown the derivation, where each stage is easy to handle: $$ Z = r - W, \qquad W \equiv \min\{ V, r \} , \qquad V \equiv \min\{ X, Y \} \tag{$\bigstar$} \label{Eq_breakdown} $$

The cumulative function of $V$ is elementary in order statistics.

$$F_V(v) = 1 - \bigl( 1 - F_X(v) \bigr)\bigl( 1 - F_Y(v) \bigr) \tag{3} \label{Eq_CDF_of_V}$$

The density of $V$ is, with the indicator notation to make things explicit, $$f_V(v) = \left[ f_X(v) \bigl( 1 - F_Y(v)\bigr) + f_Y(v) \bigl( 1 - F_X(v)\bigr) \right] \ind{v>0} \tag{4} \label{Eq_density_of_V} $$

Accordingly, the density of $W$ can be obtained just like how you got Eq.\eqref{Eq_density_of_n=1} for $\max\{ r - X, 0\}$ in the case of $n=1$.

$$f_W(w) = \begin{cases} 0 &,~~ w < 0\\ f_V(w) &,~~ 0\leq w < r\\ \text{atom} &,~~ w = r~~, \quad \small\text{where the atom is a point mass}~~ 1 - F_V(r)\\ 0 &,~~ w>r \end{cases}$$

Alternatively, in its compact form like Eq.\eqref{Eq_delta_ind_example} we have: $$f_W(w) = f_V(w)\ind{0 \leq w < r} + \bigl( 1 - F_V(r) \bigr) \delta(w-r) \tag{5} \label{Eq_density_of_W} $$ where I'll keep $f_V$ and $F_V$ symbolic and plug them in only at the end.

Apply the transformation like Eq.\eqref{Eq_transformation_example} with the mapping $Z = r - W$. The inverse mapping is $W = r - Z$, which Jacobian is $-1$. Substitute $w = r - z$ in Eq.\eqref{Eq_density_of_W} we have $$ f_Z(z) = f_V(r-z) \ind{0 \leq r-z < r} + \delta(-z) \bigl( 1 - F_V(r) \bigr) $$ The Dirac delta function is symmetric $\delta(-z) = \delta(z)$, and the indicator function evaluates to $\ind{0 \leq r-z < r} = \ind{0 \leq r-z} \cdot \ind{r - z < r} = \ind{0 < z \leq r}~$. Note that this support for $z$ is essentially the same interval $0$ to $r$ for $w$, with the technicality that the equal sign (closed-ness) changes sides. $$f_Z(z) = \begin{cases} 0 &,~~ z < 0\\ \text{atom} &,~~ z = 0~~, \quad \small\text{where the atom is a point mass}~~ 1 - F_V(r)\\ f_V(r-z) &,~~ 0< z \leq r\\ 0 &,~~ z>r \end{cases} \tag{6} \label{Eq_density_of_Z}$$ This confirms the guess made (about the structure) in the earlier section What We Already Know Without Calculation.

Now we plug in $f_V$ and $F_V$ as seen in Eq.\eqref{Eq_density_of_V} and $F_V$ in Eq.\eqref{Eq_CDF_of_V}. There's the atom $\mathbb{P}\{ Z = 0 \} = \bigl( 1- F_X(r) \bigr)\bigl( 1- F_Y(r) \bigr)$ while the density is zero except for $0 < z \leq r$ where it is

$$f_Z(z) = f_X(r-z) \bigl( 1- F_Y(r-z) \bigr) + f_Y(r-z) \bigl( 1- F_X(r-z) \bigr)$$

In the special case of identical distribution, $X \overset{d}{=} Y \sim f$, we have $$\bbox[5px,border:2px solid #C0A000]{~\mathbb{P}\{ X^{(r)} = 0 \} = \bigl( 1- F(r) \bigr)^2~~, \qquad f_{ X^{ (r) } }(x) = 2f(r-x) \bigl( 1- F(r-x) \bigr) \quad \text{for}~ 0 < x \leq r~}$$ Back to the notation of $X_1$ and $X_2$, then $f$ is the density common to $X_1$ and $X_2$, while $f_{X^{(2)}}$ is of course the density of $\min\{ X_1, X_2\}$, with the argument plugged in as $r-x$.

Alternative Derivation with diagram for $n = 2$

If one would like to have some "geometric" sense of what's going on, there's always the approach that explicitly deals with the regions of integration. $$\mathbb{P}\bigl\{ Z < z \bigr\} = \mathbb{P}\bigl\{ Z = r - X < z \bigr\} + \mathbb{P}\bigl\{ Z = r - Y< z \bigr\} $$ In the end one will take the derivative with respect to $z$ and obtain the density.

Consider the first term $\mathbb{P}\bigl\{ Z = r - X < z \bigr\}$ in the region $Z = r - X$, which itself has two regions:

\begin{align*} r - X &> r - Y > 0 & \implies& \begin{cases} X &< r \\ Y &< r \\ Y &> X \end{cases} &&\text{, lower left triangule (blue)}\\ \\ r - X &> 0 > r - Y & \implies& Y > r > X &&\text{, upper-left block (blue)} \end{align*}

Left Diagram: blank white space top right quadrant of view, entire left half region is blue, meeting entire lower half of orange at the diagonal;  Right Diagram: similar to left diagram but all white, except part of left colored green and red

The region $Z = r - X$ is shown as blue in the left figure above, where $Z = 0$ is the blank region (upper right quadrant).

The region $Z = r - X < z $ is accordingly the part of the two regions respectively: \begin{align*} \color{magenta}{z >} r - X &> r - Y > 0 & \implies& \begin{cases} X &> \color{magenta}{r - z}\\ Y &< r \\ Y &> X \end{cases} &&\text{, red triangle} \\ \\ \color{green}{z >} r - X &> 0 > r - Y & \implies& Y > r ~~\& ~~ X > \color{green}{r - z} &&\text{, green band} \end{align*} Again, recall the argument (about the "structure" of the distribution) in the earlier section What We Already Know Without Calculation, we know the relevant region (where density is non-zero) is only $0 < z < r$.

Anyway, one can go ahead and setup the integral and take the derivative. Eventually one will arrive at Eq.\eqref{Eq_density_of_Z} just the same.

Conclusion and Generalization to any $n$

If this is the first time one encounters the density written in Dirac delta and indicator function, then the algebraic derivation might seem formidable.

If one is already familiar with such density formulation (which includes the "domain"(support) and mixture with atom as part of the function), then arguably the algebraic derivation provides a conceptually clean derivation.

Breaking down the transformation (shifting and flipping max to min) tells you why the final result takes the form: the 4-segment-structure and the appearance minimal statistic.

More importantly, it is readily generalized to any $n$: just replace the random variable $V$ in the derivation Eq.\eqref{Eq_breakdown} from the very beginning by the general minimal statistic

$$X_{(1)} \equiv \min\{ X_1,\, X_2, \ldots,\, X_n\}~,$$

where the $X_i \geq 0$ are independent but not necessarily identical.

There is no doubt that the outcome Eq.\eqref{Eq_density_of_Z} generalizes to $$f_{ X^{ (r) } }(x) = \begin{cases} 0 &,~~ z < 0\\ \text{atom} &,~~ x = 0~~, \qquad \text{where the atom is a point mass}~~ 1 - F_{(1)}(r)\\ f_{(1)}(r-x) &,~~ 0< x \leq r\\ 0 &,~~ x>r \end{cases}$$ where $F_{(1)}$ and $f_{(1)}$ are the CDF and density of $X_{(1)}~$: $$F_{(1)}(t) = 1 - \prod_{i = 1}^n \bigl( 1 - F_i(t) \bigr)~~, \qquad f_{(1)}(t) = \sum_{i = 1}^n \left[ f_i(t) \prod_{j \neq i} \bigl( 1 - F_j(t) \bigr) \right]$$ In the special case where $X_i$ are all identical with common $f$ and $F$, $$F_{(1)}(t) = 1 - \bigl( 1 - F(t) \bigr)^n~~, \qquad f_{(1)}(t) = n f(t) \bigl( 1 - F(t) \bigr)^{n-1}$$ In particular, the atom becomes $\mathbb{P}\{ X^{(r)} = 0\} = \bigl( 1 - F(t) \bigr)^n$.

In the sort-of-geometric derivation, indeed one can visually see that $X^{ (r) }$ takes such regions with the "same shape" corresponding to a minimal statistic. In the case of $2$-sim, the region is an infinite band capped by a triangle. In $3$-dim, it's an infinite column (with square cross section) capped by a tetrahedron. In higher dimensions, the shape is a hyper-column capped by an $n$-simplex. However, the analysis of the regions using the diagram become very tedious for $n \geq 3$, compared with the neat little algebraic treatment. $\endgroup$