# Maximum likelihood estimate of hypergeometric distribution parameter

Using the notation in the Wikipedia article on the hypergeometric distribution, I'm curious how one would obtain the maximum likelihood estimate for parameter $m$, the number of white marbles, given $T$ trials from the same urn. For convenience, I'll copy/paste the notation from the article:

Suppose you are to draw $n$ marbles without replacement from an urn containing $N$ marbles in total, $m$ of which are white. The hypergeometric distribution describes the distribution of the number of white marbles drawn from the urn, $k$.

Again, assuming I conduct $T$ trials, at each trial, I take $n$ balls from the urn, and $k_i$ is the number of white balls at trial $i$. Define $K = (k_1,\ldots,k_T)$. Then the likelihood function $L$: $$L(m; K, N, n) = \prod_i^T \frac{\binom{m}{k_i}\binom{N-m}{n-k_i}}{\binom{N}{n}}$$

Taking a hint from this post, I first tried to solve the inequality: $$L(m;K,N,n) \geq L(m-1;K,N,n)$$ when $T=1$. From this I obtained $$m \leq \frac{Nk+k}{n}$$ so the MLE should be $$m = \left\lfloor \frac{Nk+k}{n} \right\rfloor$$

Now, I'm stuck when I try to generalize to $T \geq 2$.

I first tried doing the same as above and I ended up with the following unwieldy inequality: $$\prod_i^T \frac{m}{m-k_i} \geq \prod_i^T \frac{N-m+1}{N-m-n+k_i+1}$$ which I'm not sure how to solve.

Then I tried to take the log of the likelihood and differentiate as if $m$ were defined over positive reals and I ended up with an equally unwieldy equation to solve: $$\sum_i^T \left(\Psi(m+1) - \Psi(m-k_i+1) - \Psi(N-m+1) + \Psi(N-m-n+k_i+1)\right) = 0$$ where $\Psi$ is the digamma function (i.e. the derivative of the log-gamma function).

My intuition tells me the solution to either of the above would look something like this: $$m = \left\lfloor \frac{(N+1)\sum_i^T k_i}{Tn} \right\rfloor$$ but I have no idea how to get here.

The motivation for this problem is pure curiosity, since I've never seen a MLE for the hypergeometric distribution in terms of $m$.

-

Here is an approximate solution. The Poisson approximation to the hypergeometric disribution valid for $\frac{m}{N}<<1$ and $n>>1$, has the form:

$P(K = k|n, M, N) = \frac{exp(-\frac{nm}{N}) (\frac{nm}{N})^k}{k!}$

The likelihood function becomes

$L(m;n,N) = \frac{exp(-\frac{Tnm}{N}) (\frac{nm}{N})^{\sum_i^T k_i}}{\prod_i^T k_i!}$

which can be easily solved to obtain:

$m = \frac{N\sum_i^T k_i}{Tn}$

-

The condition you obtained $$\prod_{i=1}^T \frac{m}{m-k_i} \geq \prod_{i=1}^T \frac{N-m+1}{N-m-n+k_i+1}$$ is correct. Rewriting it as $$\prod_{i=1}^T \left(1+\frac{k_i}{m-k_i}\right) \geq \prod_{i=1}^T \left(1+\frac{n-k_i}{N-m-n+k_i+1}\right)$$ makes obvious the fact that the LHS is a decreasing function of $m$ and the RHS is an increasing function of $m$. Let $k^*$ denote the minimum value of $k_i$ over $i$. When $m\to k^*$, $m>k^*$, the LHS goes to infinity and the RHS stays finite. When $m\to N-n+k^*+1$, $m<N-n+k^*+1$, the LHS stays finite and the RHS goes to infinity. These observations prove that there exists a unique maximum likelihood estimator of $m$.

Its value is close to the root of a polynomial in $m$ whose degree is a priori at most $2T$. The terms of degree $2T$ cancel and a careful inspection shows that the coefficient of $m^{2T-1}$ is $nT$, hence not zero (this fact alone is sufficient to prove that there exists at least a solution since the degree of the polynomial is odd).

Finally one must find the unique root in the relevant range of a polynomial of degree $2T-1$ hence a closed form formula for the maximum likelihood estimator of $m$ is unlikely when $T\ge3$, the cases $T=1$ (linear polynomial) and $T=2$ (degree $3$ polynomial) being solvable.

-