Formula for calculating sample size for hypergeometric distribution Suppose you have an urn with "N" marbles.  All marbles are either black or white.  You take a sample of size "n" without replacing them to the urn.  
With this one sample you would like to be able to make one of the following two statements:


*

*Y% or greater of the marbles are white.

*Less than Y% of the marbles are white.


Thoughts:


*

*This approach uses the hypergeometric distribution.

*In practice, my "N" will be large (1*10E5 to 1*10E6).


Questions:


*

*What is the size of "n"? 

*What is the formula for calculating the required sample size "n"? 

*How to estimate the confidence interval for Y?


Thanks in advance.
 A: First of all for background:
“The hypergeometric distribution applies to sampling without replacement from a finite population whose elements can be classified into two mutually exclusive categories like Pass/Fail” (Wikipedia)
That being said, if your sample size is extremely large it is possible that even without replacement your results may approximate the binomial distribution.
Equation for sample size calculation for small populations:
Hypergeometric distribution
 = (^2 ) / ((^2 (−1)+^2 ))
Where:


*

*n  =  Minimum sample size

*N  =  Population size

*z  =  Confidence level  (zα/2)

*p  =  Proportion of events in population

*q  =  Proportion of non-events in population

*E  =  Accuracy of sample proportions


Simple binomial distribution (included for comparison)
=(^2 )/^2 
Useful links and resources:
My current reputation prevents me from posting more than 2 links so please vote this answer up if it is helpful to you: 
Formula and examples: University of Regina 
Online calculator
Google has the book: "Six sigma and beyond"
Useful examples on "stattrek.com"
Wolfram Alpha 
digitheadslabnotebook.blogspot.com
A: Using the formula provided by Stan in his answer to his own question and plugging in the values for $N$, $p$ and $q$ in the question, i.e.
Population: $N = 1,000,000$
proportion of white marbles: $p = 0.001$ 
proportion of black marbles: $q = 1 - p$
and assuming a precision
$E = 0.05$
we end up with 
$$
n = \frac{1,000,000 \cdot z_{1-\alpha / 2}^2 \cdot 0.000999}{2499.998 + z_{1-\alpha / 2}^2 \cdot 0.000999}
$$
Here we need a clarification:
$z$ is not the confidence level but usually interpreted as the $(1-\alpha/2)$ quantile of the standard normal Distribution.
The confidence level is $1-\alpha$.
Typical values of $\alpha$ are 0.01, 0.05 and 0.1 and are set to control the probability of error type 1 in hypothesis testing. Wikipedia
Using the $(1-\alpha/2)$ quantile implies we want to conduct a two sided hypothesis test (otherwise we would have to use the $(1-\alpha)$ quantile).
Back to the example:
Let's use $\alpha = 0.01$, i.e. an 99% confidence level. Now we get a result for sample size $n$:
$$
\begin{align}
n &= \frac{1,000,000 \cdot 2.58^2 \cdot 0.000999}{2499.998 + 2.58^2 \cdot 0.000999}\\
&= 2.6513
\end{align}
$$
Discussion of result:
Clearly it is impractical to draw 2.6513 marbles from the urn. Thus drawing 2 or 3 marbles are the options to choose from.
Neither would be very satisfying... 
Imagine we opt for drawing 3 marbles. What are the probabilities of drawing 0, 1, 2 or even 3 white marbles?
$P(0) = 0.997003$
$P(1) = 0.002994009$
$P(2) \approx 0$
$P(3) \approx 0$
Regarding a hypothesis test $H_0: p_0 = 0.001$ we are fine because the chances of rejecting the true hypothesis are at most 1% (as required by setting $\alpha = 0.01$).
Caution:
If it is not just about hypothesis testing but also about estimating the proportion of white marbles in the population you would not want to do this based on a sample size of just 3, because your estimate would be limited by design to the values 0%, 33.3%, 66.% or 100%. Not quite what you had in mind when specifying a precision of 0.05 (i.e. 5 percentage points).
