Skip to content
All library documents

Computing Quantiles for the Normal Inverse Gaussian Distribution

Article Quant Q&A · Author: miradulo

Summary

The discussion considers how to obtain accurate quantiles for the Normal Inverse Gaussian (NIG) distribution, used here to model drivers of interest rate implied volatility risk. The questioner values the distribution’s parsimony and closure under convolution, but is unsure how much to trust available implementations after a custom C# calculation agrees with an R function to only about five digits.

The answers explain that the NIG quantile has no closed-form expression, so implementations generally find it numerically by solving for the cumulative probability. Accuracy therefore depends on the root-finding method and its stopping criteria. Suggested ways to check results include comparing implementations across statistical libraries, using an inverse Gaussian distribution and a root finder in MATLAB, or using an implementation for the broader generalized hyperbolic family, which includes NIG. The discussion offers no definitive benchmark or independent accuracy test. It also questions whether precision beyond the reported level matters for the research application, making the required tolerance an important practical choice.

Key ideas

  • The NIG quantile has no closed-form formula, so numerical root finding is generally required.
  • Reported accuracy depends on the solver and its stopping criteria.
  • Comparing independent implementations can help assess numerical results, though it does not establish a definitive benchmark.
  • NIG is a special case of the generalized hyperbolic distribution, whose implementations may provide a quantile function.
  • The precision required should be judged against the needs of the model and application.

Tags

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


# 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.

## Answer by Brian B (score 3, accepted)

https://quant.stackexchange.com/a/22752

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?

## Answer by Dr_Be (score 2)

https://quant.stackexchange.com/a/22753

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.

## Answer by jaehyukchoi49 (score 1)

https://quant.stackexchange.com/a/42306

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

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.