I have the following problem:
$n$ values $U_1, \ldots, U_n$ are chosen randomly and independently from the interval $[0,1]$.
When choosing $U_i$, the probability that $U_i$ is smaller than a certain $x$ is $\Pr(U_i \lt x) = f(x)$. For this example let's assume $f(x) = x^2$ (i.e. $\Pr(U_i \lt x) = x^2)$, although a generalization would be welcome.
The question is: after sorting the $n$ values, what is the expected value of the $K$'th element? In other words, if $U_1 \lt \ldots \lt U_n$, then what is the expected value of $U_K$?
I have tried to apply the following logic:
I want to find the $K$'th largest element, so I want to compute the probability that $K$ numbers are smaller than $x$ and $N - K$ numbers are greater than $x$. Since the values are chosen independently, I have $F(i) = \Pr(U_i < x)^{K} (1 - \Pr(U_i < x))^{n - K}$. In our example, that would be $F(i) = x^{2k}(1-x^2)^{n - K}$. I take the derivative of this function to find the density function $F'(x)$, then I integrate $xF'(x)$ on $[0,1]$ to get the expected value. However, this gives me a negative value ($\approx -0.133$) for $n=2$ and $K=1$, so I figure it must be wrong.
Can someone lend me a hand? Thank you in advance.
Your idea is on the right path but you are missing something. $F(i)$ in your notation is the probability that some $U_{i_1},\ldots,U_{i_K}$ values are smaller than $x$, however you can pick indexes $i_1,\ldots,i_K$ in $\binom{n}{K}$ ways therefore the probability that $U_{(K)}$ ($K^{\text{th}}$ order statistic = $K^{\text{th}}$ smallest element) is smaller than $x$ is
$$P[U_{(K)} \leq x ] = \binom{n}{K} \left( P(U_1 \leq x ) \right)^K \left( 1- P(U_1 \leq x ) \right)^{n-K} $$
Edit: In the equation above I denoted $U_{(K)}$ the $K^{\text{th}}$ smallest element, what would change if you need $K^{\text{th}}$ largest element?