Combinatorics: Under-counting the probability of an outcome I have a computer science homework problem which deals with the probability of an input set being "ideal." I won't go into details about the application, but here is my mathematical understanding of it.
Consider a sorted list $L$ consisting of $n$ numbers. The numbers at from indices $n/4$ to $3n/4$ are considered "good" numbers. That means that if you select any element of $L$ at random, there is a $1/2$ chance it will be a "good" number, a $1/4$ chance it will be a "low bad" number, and a $1/4$ chance it will be a "high bad" number.
If I select 3 numbers from $L$ at random (repetitions are allowed), then what is the probability that the median of the three numbers will be a "good" number?
The way I see it, there are two bad cases and three good cases:


*

*BAD: None of the numbers selected are in the "good" range. I initially calculated the probability of this to be
$$
\left(\frac{1}{4}+\frac{1}{4}\right) \cdot \left(\frac{1}{4}+\frac{1}{4}\right) \cdot \left(\frac{1}{4}+\frac{1}{4}\right) = \frac{1}{8}
$$

*BAD: One of the numbers selected is in the "good" range, but the other two numbers are both in the same "bad" range (either both "low bad" or both "high bad").
$$
\frac{1}{2} \cdot \left( \frac{1}{4} \cdot \frac{1}{4} + \frac{1}{4} \cdot \frac{1}{4} \right) = \frac{1}{16}
$$

*GOOD: All of the numbers selected are in the "good" range.
$$
\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{8}
$$

*GOOD: Two of the selected numbers are in the "good" range.
$$
\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{8}
$$

*GOOD: Only one of the selected numbers is in the "good" range, but the other numbers are in opposite "bad" ranges.
$$
\frac{1}{2} \cdot \left( \frac{1}{4} \cdot \frac{1}{4} + \frac{1}{4} \cdot \frac{1}{4} \right) = \frac{1}{16}
$$


And here's where I'm stumped. The sum of these probabilities is $1/2$, and I don't believe there are any other cases to consider. I believe this might be solved with combinatorics, but all examples I have seen deal with equally-distributed sample sizes ("in a bag there are 4 balls of each of the following colours...") and I'm not sure how to translate the concept to this problem.
 A: In case 2 you have only counted the cases where the first number you select is good.  You should multiply by $3$ for the three different positions the good number is in.  This adds $\frac 18$ to your total.  For case 4 you should multiply by $3$ for selecting which of the numbers is bad.  That multiplies adds $\frac 14$ to the total.  For case 5 you should multiply by $3$ to account for the ordering of the low, good, and high numbers.  This adds $\frac 1{8}$ to the total.  That brings the total to $1$ as expected.
A: Consider cases, based on the number of good numbers . . .

For the median to be good, we need at least one good number.

Case $(1)$:$\;$Exactly $1\;$good number.


*
The probability of exactly $1\;$good number is: $\;\binom{3}{1}\left(\frac{1}{2}\right)^3=\frac{3}{8}$.


The factor $\binom{3}{1}$ is needed to account for which of the $3$ selections is good.

But we have to worry about the types of the selected bad numbers . . .

The two bad numbers are either (low,high), (high,low), (low,low), (high,high), with all $4$ pairs equally likely. 

For the good number to be a median, we can only allow the  pairs (low,high), (high,low), hence, given that case $(1)$ occurs, the probability of a good median is $\frac{1}{2}$.


Case $(2)$:$\;$Exactly $2\;$good numbers.


*
The probability of exactly $2\;$good numbers is: $\;\binom{3}{2}\left(\frac{1}{2}\right)^3=\frac{3}{8}$.


The factor $\binom{3}{2}$ is needed to account for which $2$ of the $3$ selections are good.


Case $(3)$:$\;3\;$good numbers.


*
The probability of $3\;$good numbers. is: $\left(\frac{1}{2}\right)^3=\frac{1}{8}$.


Of the three cases, cases $(2)$ and $(3)$ always yield a good median.

For case $(1)$, to get a good median, we need to apply the factor $\frac{1}{2}$.

Thus, summing the results for all three cases, the probability of a good median is
$$
\left({\small{\frac{1}{2}}}{\,\cdot\,}{\small{\frac{3}{8}}}\right)
+
\left({\small{\frac{3}{8}}}\right)
+
\left({\small{\frac{1}{8}}}\right)
=
{\small{\frac{11}{16}}}
$$
