Confidence interval on extrapolation from sample? Suppose I have a set of N items.
Some of them are red and some of them are blue.  I don't know how many of each.
Suppose I take a random sample of M items and discover that K of that sample are red.
All I can say with total certainty is that there are between K and K+N-M red items in the set of N, but lets say I only want to be P (between 0.0 and 1.0) certain that the number of red items is between A and B.
Given N,M,K and P - how do I calculate A and B?
I think this is a "confidence interval" right? or something like that.
I'm sure this is a common statistics problem, but I'm not sure what it is called.
 A: From what you say, I suppose sampling is 'without replacement'.
That means the number $K$ of red items out of $M$ has a 'hypergeometric' distribution. 
You can consider that you are
trying to estimate the proportion of red items in the population
of $N$ items or the actual number of red items out of $N$.
The point estimate of the proportion is $\hat p = K/M$, and you do want
a 'confidence interval' to give you an idea how close that point
estimate is likely to be to the actual proportion. (Multiply
the endpoints of that interval by $N$ and you'd have a 
confidence interval for the actual count of red items.)
If the number $K$ sampled is relatively small with respect to $N$
(say maybe less than 10%), then you can often use a binomial or normal distribution as a simplification to get serviceably accurate
confidence intervals.
It would be redundant for me to go into the details here
because the topic is quite clearly discussed in articles
on the Internet that you can fetch with 'hypergeometric
confidence interval'. I have just had a look at some of them
to make sure this is a reasonable assertion. For example, the notes
by Prof Tesler at UCSD (perhaps starting at about Sect 3.2)
has both good explanations and formulas.
If this is a question about actual data instead of a theoretical homework
problem, please make an 'addendum' to your question with values of
$K,\,N,\,M$, etc.---perhaps along with your proposed confidence
interval. Then I or someone else can take a look to give more
specific help, and to see if your confidence interval is reasonable.
