# Approximate solve?

I'm trying to solve the probability that a cumulative discrete distribution (specifically, the negative hypergeometric distribution) equals 0.5 for a particular parameter $\in \mathbb{N}$. Since it's discrete, there is no exact solution, but I was wondering if Mathematica had a way to find the nearest solution. At this point I'm reduced to plugging in and guessing, and NSolve is not working (probably because its not just checking the naturals).

So I need a approximate solution $\in \mathbb{N}$ that may not be very close.

Edit:

Here's the code:

Solve[.5 ==
Sum[
(Binomial[k + 1 - 1, k]*Binomial[540000 - 1 - k, 539000 - k])
/
(Binomial[540000, 539000]
),
{k, 1, n}
],
n, Integers]

The (approximate) solution is 375.

• FindMinimum of the distribution minus 0.5 could work. – Marius Ladegård Meyer Aug 15 '17 at 7:26
• Welcome to Mathematica Stack-Exchange! In general people get much better answers when they copy and paste (as text) the actual Mathematica they've tried. A non-obvious advantage of doing so: not everyone on MSE is a native english speaker, but everyone here speaks Mathematica, so you'll reach a much wider audience. It takes a little longer but it ends up making both the question and subsequent answers much more valuable. – John Joseph M. Carrasco Aug 15 '17 at 8:42
• InverseCDF[] or Quantile[] are usable if your distribution is expressible in terms of built-ins. – J. M.'s discontentment Aug 15 '17 at 14:51
• For some reason the negative hypergeometric isn't built in. – ketchup Aug 15 '17 at 23:40

As noted in the docs, the negative hypergeometric is expressible in terms of BetaBinomialDistribution[]:

NegativeHypergeometricDistribution[r_, nsucc_, ntot_] :=
BetaBinomialDistribution[r, ntot - nsucc - r + 1, nsucc]

Check:

FullSimplify[(Binomial[k + 1 - 1, k] Binomial[540000 - 1 - k, 539000 - k])/
(Binomial[540000, 539000]) ==
PDF[NegativeHypergeometricDistribution[1, 539000, 540000], k],
0 <= k <= 539000]
True

Thus, your problem is solved by either of

Quantile[NegativeHypergeometricDistribution[1, 539000, 540000], 1/2]
373

or

InverseCDF[NegativeHypergeometricDistribution[1, 539000, 540000], 1/2]
373