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.
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.