Wednesday 18 July 2012

Inverting the STANDARD Cumulative Normal Distribution in Excel and C++

For various financial applications, you will need to invert the cumulative standard normal distribution. The correct Excel worksheet function for this is:

NORMSINV

You need to give it a number between 0 and 1. The function NORMSINV is confusing, because the name does not allude to the fact that we are inverting the CUMULATIVE normal distribution. (NORMINV is the cousin of NORMSINV that inverts the Normal Distribution more generally. Consequently, mean and standard deviation parameters must be specified explicitly. NORMSINV can be regarded as a special case of NORMINV that just accepts a probability as parameter).

Here is an algorithm for computing the inverse cumulative normal distribution. Note that the function is a continuous, non-linear (curve rather than a straight line) function and maps the (0,1) open interval on the x-axis into the entirety of the real line (although most visibly between -3 and 3 on the y-axis). It's very important to understand visually what this function is, to avoid confusing it with any other related function.

If you want to do this in Visual C++, then the Boost Math library (written by John Maddock and Paul Bristow) will do the needful.

Boost implements a generalized version of this, using the notion of Quantiles. A quantile can be thought of as the inverse of a Cumulative Distribution Function, returning a value x such that cdf(dist, x) == p. The quantile is also known as the percent point function, or percentile, or the lower critical value of the distribution.

Summary: Quantile = Inverse CDF

To understand the Boost API, we should also understand what is the complement of the cumulative distribution function. This is the probability that a variable take a value greater than x.

No comments: