TITLE: I pull $17$ balls out of a bag, and there are $13$ distinct colors in the sample. About how many colors are in the bag?
QUESTION [7 upvotes]: I have a bag filled with different colors of balls.  My goal is to determine the number of distinct colors that in the bag, but I am limited to taking a small sample.  From a sample of $N$ balls, I see that there $X$ different colors.  What is the expected number of different colors in the bag?
Some assumptions which need to be made:

The bag is of sufficiently large size that the probability of drawing a certain color does not depend on the how many balls we have already drawn.  (Effectively, we are drawing with replacement.)
There is an equal number of each color in the bag.

For an example, let's say that I draw $N=17$ balls out of the bag, and I see $X=13$ distinct colors.  What is a good estimate for the number of colors in the bag?
So far, I have made little progress towards answering this on my own. I have tried to reverse the solution to the coupon collector's problem (as to solve for the number of colors as opposed to the number of trials), but I became stuck since it involved the harmonic numbers.

REPLY [3 votes]: If the sample is size $n$, the likelihood you see $X=x$ different colours when there are $Y=y$ possible colours is proportional to $$\dfrac{y!}{(y-x)! y^n}.$$
So given $X=x$, the maximum likelihood estimate for $Y$ is the positive real solution to  $y(y-1)^n -(y-x) y^n=0$ rounded down, or in other words the largest integer $y$ for which the left hand-side is non-negative. (Note that if $x=n$ the maximum likelihood estimate is infinite.) 
In this particular case with $n=17$ and $X=13$, the maximum likelihood estimate for $Y$ is $28$. 
The uncertainty is considerable: any value for $Y$ from $15$ through to $91$ would have a likelihood for seeing $13$ unique colours from a sample of $17$ more than a tenth of the likelihood resulting from $Y=28$.