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.


Here's the code:

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

The (approximate) solution is 375.

  • $\begingroup$ FindMinimum of the distribution minus 0.5 could work. $\endgroup$ Aug 15, 2017 at 7:26
  • $\begingroup$ 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. $\endgroup$ Aug 15, 2017 at 8:42
  • $\begingroup$ InverseCDF[] or Quantile[] are usable if your distribution is expressible in terms of built-ins. $\endgroup$ Aug 15, 2017 at 14:51
  • $\begingroup$ For some reason the negative hypergeometric isn't built in. $\endgroup$
    – ketchup
    Aug 15, 2017 at 23:40

1 Answer 1


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]


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

Thus, your problem is solved by either of

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


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.