# Python – Inverse of Normal Cumulative Distribution Function (CDF)

## Problem Formulation

How to calculate the inverse of the normal cumulative distribution function (CDF) in Python?

## Method 1: scipy.stats.norm.ppf()

In Excel, NORMSINV is the inverse of the CDF of the standard normal distribution.

In Python’s SciPy library, the `ppf()` method of the `scipy.stats.norm` object is the percent point function, which is another name for the quantile function. This `ppf()` method is the inverse of the `cdf()` function in SciPy.

• `norm.cdf()` is the inverse function of `norm.ppf()`
• `norm.ppf()` is the inverse function of `norm.cdf()`

You can see this in the following code snippet:

```from scipy.stats import norm

print(norm.cdf(norm.ppf(0.5)))
print(norm.ppf(norm.cdf(0.5)))```

The output is as follows:

```0.5
0.5000000000000001```

An alternative is given next:

## Method 2: statistics.NormalDist.inv_cdf()

Python 3.8 provides the `NormalDist` object as part of the `statistics` module that is included in the standard library. It includes the inverse cumulative distribution function `inv_cdf()`. To use it, pass the mean (`mu`) and standard deviation (`sigma`) into the `NormalDist()` constructor to adapt it to the concrete normal distribution at hand.

Have a look at the following code:

```from statistics import NormalDist

res = NormalDist(mu=1, sigma=0.5).inv_cdf(0.5)
print(res)
# 1.0```

A great resource on the topic is given next.

References:

Do you want to become a NumPy master? Check out our interactive puzzle book Coffee Break NumPy and boost your data science skills! (Amazon link opens in new tab.) 