Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the [Sci/Num]Python equivalent to Matlabs "norminv" (Normal inverse cumulative distribution function) [duplicate]

I am searching for a python equivalent of the norminv function in Matlab.

Or in other words (from the above description): I am searching for the "Normal inverse cumulative distribution function" in python, or probably in the stats part of scipy (Or maybe numpy?)

I would guess that it exists in scipy, but probably under another name than in matlab, or in matlabs help page. However I am not sure of this functions other names, or exact workings, so I am having a hard time finding it. And unfortunately it's not simply the "Inverse normal cumul…" instead of the "Normal inverse cumul…"

like image 562
JC_CL Avatar asked Mar 31 '15 13:03

JC_CL


1 Answers

It depends exactly on what you want. If you want the cdf of a distribution that is the inverse of the normal distribution, you want invgauss, "An inverse Gaussian continuous random variable.". To get the cdf, you would need to use the invgauss.cdf method. Adapted from the documentation:

from scipy.stats import invgauss
mu = 0.145462645553
vals = invgauss.ppf([0.001, 0.5, 0.999], mu)
res = invgauss.cdf(vals, mu)

On the other hand, if you want the inverse of the cdf of the normal distribution, you want the ppf method of the norm distribution, which is the "Percent point function (inverse of cdf — percentiles)."

like image 164
TheBlackCat Avatar answered Nov 13 '22 12:11

TheBlackCat