I am using python to calculate Inverse of a CDF of gamma distribution (using scipy. stat.gamma.fit). But for probability value 1, it is coming infinite. If it is replaced from 1 to 0.99 it works but the values changes with the different number of significant figures. Like it is 61 for 0.99 and 130 for 0.9999.

I do not know the best way to handle these infinite values in my workflow.I need to get a ideals but valid inverse value for probabilities arbitrarily close to 1. But i don't know, how to decide how many digits are needed to round off the probability value. Also, I am not sure about, Will it be fine to round off?

Can we do something to get some meaningful information instead of inf value?

Thank you for your help


closed as unclear what you're asking by Michael Chernick, kjetil b halvorsen, Peter Flom Feb 13 at 10:39

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ That sounds about right. Why do you think there is a “situation” here? $\endgroup$ – The Laconic Feb 13 at 5:50
  • $\begingroup$ I need to get the best possible inverse value near to 1. But i don't know, how to decide the upto which digit it is needed to round off the probability value. Also, I am not sure about, Will it be fine to round off? $\endgroup$ – user10423946 Feb 13 at 7:17
  • $\begingroup$ What does "best possible inverse value near to 1" mean? How near? $\endgroup$ – Peter Flom Feb 13 at 10:39
  • $\begingroup$ The correct value of the inverse CDF of all Gamma distributions at the argument $1$ is $+\infty.$ It sounds like your software is giving you the right answer. $\endgroup$ – whuber Feb 13 at 14:38
  • $\begingroup$ yes..that is correct but @ReeBt well explained my problem $\endgroup$ – user10423946 Feb 13 at 15:31

Probability of 1 for an event means it will occur at every single possible instance. This means that in an infinite population an infinite number of events will occur. As @thelaconic suggests this is exactly what we expect.

I am guessing you need a solution that allows the algorithms to continue to provide meaningful results when applied. The best generic best solution is to detect inf (and >N) results and get your algorithm to insert N (number of instances) in the place of inf. That will allow you to apply the abstract inverse cdf to the actual dataset.

  • $\begingroup$ yes you are right.... i am looking for that only $\endgroup$ – user10423946 Feb 13 at 15:27
  • $\begingroup$ In that case, if the answer has resolved your question please accept this as the answer or if not then indicate what further issues need addressed. Cheers. $\endgroup$ – ReneBt Feb 14 at 9:21

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