# calculus - Approach at maximizing this equation?

$$f(\phi) = \frac{{ n_1\choose x }{ n_2 \choose t-x } \phi^x}{\sum_{u=1}^t { n_1\choose u }{ n_2 \choose t-u } \phi^u}$$

I'm trying to maximize the above function, but I am having trouble.

I start by taking the log of the function and taking the derivative. Doing so gives me

$$ \frac{x}{\phi} - \frac{\sum_{u=1}^t { n_1\choose u }{ n_2 \choose t-u } u \phi^{u-1}}{\sum_{u=1}^t { n_1\choose u }{ n_2 \choose t-u } \phi^u}$$

Which after setting equal to 0 gives

$$\frac{\sum_{u=1}^t { n_1\choose u }{ n_2 \choose t-u } u \phi^{u}}{\sum_{u=1}^t { n_1\choose u }{ n_2 \choose t-u } \phi^u} = x$$

At this point I tried playing around with the combinatorial factorials, but it leads me know where.

I know a solution exists (as it's the MLE of a hypergeometric distribution), but I'm unsure how to determine $\phi$ given the above ratio.

Looking at the sums, I was initially thinking the trick might be the use of binomial sums, but since $n_1 \neq n_2$ I don't think that's possible?

I end up with a similar equation in a related problem:

$$x = \frac{\sum_{u=0}^t u\theta^u /u!(t-u)!}{\sum_{u=0}^t \theta^u /u!(t-u)!}$$

How on earth does one solve these? There must be a simple trick I'm missing...

## Ken-

2019-11-14

If we have a function $f(x)=g(x)/h(x)$, the derivative is $f'(x)=(g'(x)h(x)-g(x)h'(x))/(h^2(x))$, which is zero (because we want to maximise/minimise $f$) when $g'(x)h(x)=g(x)h'(x)$ (assuming that $h(x)\neq0$). In the numerator of your sum you have a constant times $x^{\mathrm{constant}}$, and in the denominator, you have a complicated looking polynomial in terms of $x$. Now just write out $g'h=gh'$ as above, since each the numerator and denominator are easily differentiated polynomials, and solve (numerically, if necessary).