# Normal Inverse Gaussian distribution - any consensus on an accurate quantile function?

I am making use of the Normal Inverse Gaussian distribution in my work to model underlying interest rate implied volatility risk drivers. What is particularly nice about this distribution for my purpose is the fact it is much more parsimonious than other alternatives, and closed under convolution.

That being said, I have not been capable of finding a reasonably "verifiable" quantile function implementation. There does not appear to be one in Excel, in R we have the function qnig from the package fBasics that I am unsure about accuracy for, and in MatLab there is this package which mentions having issues with the inverse CDF due to numerical computation.

My question is whether there exists a reasonably accurate quantile function for my purposes. I am coding in C# and attempted to implement my own Normal Inverse Gaussian function, however comparing with R's qnig I only consistently have around 5 digits of accuracy. I am not even sure if R's implementation is to be trusted as a baseline for many digits of accuracy, however.

When possible, I look at implementations in IMSL and the GSL for really good accuracy. Neither one appears to implement the Wald (inverse gaussian) or its quantile function.

Matlab does have the distribution (as inversegaussian) so you could roll your own with fzero() or another root-finder based on that if you are unhappy with the accuracy, or for testing qnig.

Since there is no closed-form formula for the quantile function, essentially every implementation will be running a root-finder. It's simply a question of the halting criteria settings for the root-finder involved.

As an aside, I have trouble thinking of a quant research project where accuracy to better than 5 (significant) digits would be important. Perhaps you just need to scale your variables?

• Very helpful, thanks. The sigdigs is more a matter of questionable management regulations. Jan 14, 2016 at 17:28
• <3 IMSL and GSL libraries Jan 14, 2016 at 17:42

You might also look at the boost package which should (I'm no expert for this) be usable within C#. It comes with an implementation of the inverse normal distribution which is explained in the online documentation http://www.boost.org/doc/libs/master/libs/math/doc/html/math_toolkit/dist_ref/dists/inverse_gaussian_dist.html

Here they claim quite a high numerical accuracy of more then 10 digits.

• That distribution is not generalized enough for tail heaviness and asymmetry for my purpose, but still I didn't know it existed, so it could be useful for others! Jan 15, 2016 at 9:52

R package GeneralizedHyperbolic has an accurate quantile function for generalized hyperbolic distribution, which include NIG as a special case.