Search code examples
pythonmatlabstatisticsdata-analysis

Matlab's binoinv equivalent in Python


Is there a Python equivalent of the binoinv Matlab function? I am new to data analysis and don't have much experience in this domain. It would really be very helpful if someone can help me out.


Solution

  • You have that functionality in scipy.stats.binom:

    • Matlab:

      >> x = binoinv([.3 .7 .9], 100, .25)
      ans =
          23    27    31
      
    • Python:

      >>> from scipy.stats import binom
      >>> x = binom.ppf([.3, .7, .9], 100, .25)
      >>> print(x)
      [ 23.  27.  31.]