Finding the probability density function of the $n$th largest random variable. Let $X_1,...,X_{25}$ be independent Unif $[0,1]$ random variables. Let $Y$ be the $13$th largest of the $25$ random variables. Find the probability density function of $Y$.
I already know the answer for this one, but the answer that was provided just told me to use a formula to get the answer without much explanation as to why I should use that formula. This was the answer I was given:
Formula: $g(x_\gamma)=\frac{n!}{(\gamma-1)!(n-\gamma)!}[F(x)]^{\gamma-1}\cdot f(x)\cdot[1-F(x)]^{n-\gamma}$
Then since $X_1,X_2,\ldots,X_{25}\sim Unif[0,1]$, we have
$$
f(x)=
\begin{cases} 
1 & \text{if } 0\leq x\leq 1 \\
0 & \text{otherwise}
\end{cases}
$$
and
$$
F(x)=\int^x_01~dx=
\begin{cases}
0 & \text{if } x<0\\
x & \text{if } 0\leq x\leq 1\\
1 &\text{if } x>1
\end{cases}
$$
Then $Y=X_{(13)}$ so
$$f(y)=\frac{25!}{(13-1)!(25-13)!}(x)^{13-1}\cdot1\cdot(1-x)^{25-13}$$
$$={^{25}C_{13}}13(x)^{12}(1-x)^{12}$$
Thus, the p.d.f. is
$$
g(Y)=
\begin{cases}
{^{25}C_{13}}13(x)^{12}(1-x)^{12} & \text{if } 0\leq x\leq 1\\
0 & \text{otherwise}
\end{cases}
$$
Could I get an explanation of why I should use this formula or if there is another way to get the answer that is more clear? Thank you.
 A: $g(x)$, or $g_{\gamma}(x)$, is the probability density of the null event that one among the sample values is exactly $x$, $\gamma-1$ among them are somewhat less than $x$, and $n-\gamma$ are somewhat above $x$.   It is the probability density function of the $\gamma$-th order statistic of a collection of $n$ iid samples.
The factor of ${^{n}\mathrm C_{\gamma}}\,\gamma$ counts how many arrangements of the samples may be used to fit this pattern: count ways to choose $\gamma-1$, $1$, and $n-\gamma$ among $n$.$${^{n}\mathrm C_{\gamma}}\,\gamma = \dfrac{n!}{(\gamma-1)!\,1!\,(n-\gamma)!}$$
The factors $f(x)$, $F(x)^{\gamma-1}$ and $(1-F(x))^{n-\gamma}$ respectively account for: the probability density that a particular sample is exactly $x$, the probability that $\gamma-1$ samples are at most $x$, and the probability that $n-\gamma$ samples exceed $x$.
Multiplying these factors will thus give the probability density function we seek:
$$g_{\gamma}(x) = {^{n}\mathrm C_{\gamma}}\,\gamma\, f(x)\, F(x)^{\gamma-1}\,(1-F(x))^{n-\gamma} $$

$$g_{13}(x) = {^{25}\mathrm C_{13}}\,13\, f(x)\, F(x)^{12}\,(1-F(x))^{12} $$

This can also be obtained by taking the derivative of the probability that $\gamma$ among the $n$ samples do not exceed $x$ .  (See also Binomial Distribution - which is derived by similar argument as above...so...)
$$g_{\gamma}(x) = \dfrac{\mathrm d ~~}{\mathrm dx} \left({^{n}\mathrm C_{\gamma}} F(x)^{\gamma}(1-F(x))^{n-\gamma}\right)$$

Often we shall use subscripts to indicate which random variable the functions belong to.  The usual convention is to use uppercase for random variables and lowercase for the function's arguments, and such.  So be aware of case sensitivity.
$$f_Y(x) = {^{25}\mathrm C_{13}}\,13\, f_X(x)\, F_X(x)^{12}\,(1-F_X(x))^{12} $$
A: First note that the $13$-largest of $25$ is also the $13$-smallest, i.e. $13$th from the bottom:
$$
\begin{array}{rcccl}
& i & & 26-i \\
\hline
\text{smallest} \rightarrow & 1 & & 25 \\ \text{2nd-smallest} \rightarrow & 2 & & 24 \\ \text{3rd-smallest} \rightarrow & 3 & & 23 \\ & 4 & & 22 \\ & \vdots & & \vdots \\
& 11 & & 15 \\ & 12 & & 14 \\ \text{13th-smallest} \rightarrow & 13 & \longleftrightarrow & 13 & \leftarrow \text{13th-largest} \\ & 14 & & 12 \\ & 15 & & 11 \\
& \vdots & & \vdots \\ & 23 & & 3 & \leftarrow \text{3rd-largest} \\ & 24 & & 2 & \leftarrow \text{2nd-largest} \\ & 25 & & 1 & \leftarrow \text{largest}
\end{array}
$$
\begin{align}
F_Y(y) = {} & \Pr(Y\le y) \\[6pt]
= {} & \Pr(\text{13 or more observations are}\le y) \\[6pt]
= {} & \Pr\big({\ge 13 \text{ successes in 25 trials with}} \\
& \qquad\quad\text{probability $y$ of success on each trial} \big) \\[6pt]
= {} & \sum_{i=13}^{25} \binom {25} i y^i (1-y)^{25-i}. \\[6pt]
f_Y(y) = {} & \frac d {dy} F_Y(y) \\[6pt]
= {} & \sum_{i=13}^{25} \binom {25} i \Big( iy^{i-1} (1-y)^{25-i} - y^i(25-i)(1-y)^{25-i-1} \Big) \\[6pt]
= {} & \left( \sum_{j=12}^{24} \binom {25}{j+1} (j+1)y^j(1-y)^{25-j-1} \right. \\
& \quad \text{(where $j=i-1$ and $i= j+1$)} \\
& \left. {} - \sum_{i=13}^{25} \binom{25} i y^i(25-i)(1-y)^{25-i-1} \right) \\[10pt]
= {} & \sum_{j=12}^{24} \binom {25}{j+1} (j+1)y^j(1-y)^{25-j-1} \\
& {} - \sum_{i=13}^{25} \binom{25} {i+1} (i+1) y^i(1-y)^{25-i-1} \\[6pt]
& \qquad \text{(since $\displaystyle \binom{25} i (25-i) = \binom{25}{i+1}(i+1) $)}
\end{align}
And now the two sums cancel each other out except the term $j=12$ and the term $i=25.$ But the term $i=25$ is $0.$ Thus we have
$$
f_Y(y) = \binom{25}{13}13 y^{12} (1-y)^{12}.
$$
