How many sets do I have? I have a jar with N objects that are grouped into sets of 3. If I randomly pull objects without replacement from this jar and my first five objects are from different sets while my sixth object is the second member of a set, how can I estimate N?
 A: You can estimate $N$ by maximum likelihood. I will write $N=3 K$, and call the $K$ sets for colors. You are pulling objects at random without replacement from the jar, until the first time you draw an already seen color. In your experiment that happened at draw 6. Write $X+1=6$, so $X$ is the last draw we see a new color. Define
$$ A_x=\{\text{Draws $1,2,\dotsc,x$ are different colors}\}
$$ Then we can calculate
$$ \DeclareMathOperator{\P}{\mathbb{P}} 
\P(A_1)=1 \\
\P(A_2)=\P(A_2 \mid A_1)\cdot \P(A_1)=\frac{3K-3}{3K-1}\cdot 1 \\
\P(A_3)=\P(A_3\mid A_2)\cdot \P(A_2) =\frac{3K-6}{3K-2}\cdot\frac{3K-3}{3K-1}\cdot 1 \\
\qquad \text{ continuing } \dots \\
\P(A_r)=\prod_{j=1}^r \frac{3K-3(j-1)}{3K-(j-1)}
$$ Then let $B_{r+1}$ be the event that we first redraw an already seen color at draw $r+1$:
$$
\P(B_{r+1})=\P(B_{r+1} \mid A_r)\cdot\P(A_r)=\frac{2r}{3k-r}\cdot \P(A_r)
$$
With the observation $X=5$ it is clear that $K$ must be at least $5$, or larger. We can plot the probability (which is our likelihood) against $K$ and read the maximum from the plot:

From the plot we can read off the maximum likelihood estimator of $K$ (a plot on smaller scale shows that is 9) and approximate confidence limits.
For the record, the R code used:
L <- Vectorize( function(K, logL=FALSE) {
    l <- log(10) - log(3*K -5)  +  sum(log(3*(K-(1:4)))) -
        sum(log(3*K - (1:4)))
    return( if(logL) l else exp(l) )
} )

axis <- 5:500

plot(axis, L(axis), type="p", color="orange", main="Likelihood function",
     xlab="K", ylab="Probability")
abline(h=0.05, col="red")
abline(h=0.01, col="blue")

