Confidence of uniformity from a sample of a binary state collection The system:


*

*I have a bag filled with 1,000 balls

*All of them are either red or blue


I want to gain some amount of confidence that all the balls are blue, but I'm very lazy and I only want to examine a sample as small as possible.
Question: How large must the sample be to say with P confidence that N balls are blue?
I'm looking for a generic answer, but here are two specific questions:


*

*How large must the sample be to say with 95% confidence that all 1,000 of the balls are blue?

*How large must the sample be to say with 95% confidence that 990 (99%) of the 1,000 balls are blue?


It's been a while with no response, so if my question is missing information or just bad for some reason, please let me know how I can improve it.
 A: Sorry if this answer is incomplete, but I can't fit it all in a comment.
If you specify a level of statistical power you want to achieve, you can use the following formula as an approximation: $n=\frac{1}{2}(b-\sqrt{b^2 + 4b(Z_p + Z_{\alpha})^2})$ where $n$ is your sample size, $b$ is the number of blue balls in the sample, $Z_p$ is the Z score for your power, and $Z_{alpha}$ is the Z score for your confidence level. Note I used $\alpha$ instead of $\alpha/2$ because it's one-tailed.
This comes from the standard power calculation for a difference in means. I just set one of them equal to 1 and ran it in Wolfram Alpha. However, this does not take the finite population into account and I don't know what the error will be like if you're sampling more than a few dozen balls at a time. In this case, "power" means the "probability of finding a red ball given that there is at least one red ball in the bag." More technically, it's the probability of rejecting the null hypothesis that the sample proportion $\hat{p}$ is equal to 1.
This is what Wolfram Alpha gave me when I slapped the finite population correction into the same formula, and it's not pretty. It's no better if you plug in $N=1000$, and no solution exists for n=b (i.e. your entire sample is blue). It reduces a bit if you plug in $N=1000$ and $.99*n=b$. I hope that helps, but I'm sure there's a better way to go about this.
A: Condition (2) implies you only need a sample of size 1.
If it is known that all the balls are one color, you only need to observe a single ball to know the color of all of them.
If it is not known that all the balls are one color, you cannot a priori rule out the possibility that exactly one ball is of a different color, in which case you should work on that worst-case -- you will need a very large random sample to be reasonably sure you haven't missed it by chance. 
In particular, if you're sampling without replacement, you would need to sample 95% of the balls to be 95% sure that there's not a single ball of a different color there. (If you sample with replacement and only take one ball each time, you need to sample almost 3000 times!)
You should clarify what is known to the person who has to decide how large a sample to take.
