Let $Y_1,\ldots,Y_n$ (all scalars) be random draws from a common CDF $F$ that has a PDF $f$. As usual, $Y_{(r)}$ denotes the $r$-th order statistic (e.g. $Y_{(1)}$ is the smallest). Let $z$ be fixed and $Q=\sum_{i=1}^n I(Y_i\leq z)$ be the number of $Y_i$'s that are less than or equal to $z$.
Let $q>0$ be a fixed positive integer. I'm trying to figure out the PDF of $Y_{(i)}$ conditional on $Q=q$. I'm actually only interested in the case when $i\leq q$. This is a step in something I'm thinking about.
Restricting to the case $i\leq q$, my guess so far is that: for $x\leq z$, the desired conditional PDF is $$ f_{(i)}(x\mid Q=q)=\frac{f_{(i)}(x)}{\binom{n}{q}F(z)^q(1-F(z))^{1-q}} $$ where $f_{(i)}(x)$ is the unconditional PDF associated with $Y_{(i)}$ $$ f_{(i)}(x)=i\binom{n}{i}F(x)^{i-1}(1-F(x))^{n-i}f(x). $$ And when $x>z$, I set $f_{(i)}(x\mid Q=q)=0$. I tried these guesses out in Mathematica with specific numerical values and exponential $F$ but the results came out all wrong.
What am I missing here? Thank you for your help!
Edit to reflect SoporificVacuum's post.
Following the approach in that post, the answer is $$ f_{(i)}(x\mid Q=q)=i\binom{q}{i}\left(\frac{F(x)}{F(z)}\right)^{i-1}\left(1-\frac{F(x)}{F(z)}\right)^{q-i}\frac{f(x)}{F(z)}. $$ for $x\leq z$ and $0$ otherwise.
So you have a sample of size $n$, $q$ of which are $\le z$, and $n-q$ of which are $>z$. The trick is that the ones $>z$ do not affect $Y_{(1)},\ldots Y_{(n)}$. Let $$g(x)=\frac{f(x)}{F(z)} I(x\le z).$$
Let $Z_1,\ldots, Z_q$ be i.i.d. with pdf $g$. Note that the order statistics of the $Z$'s are distributed identically to the first $q$ order statistics of $Y$.