0
votes

How do I sample random variates from a Normal Inverse Gaussian (NIG) distribution?

I need to generate 100 numbers from the NIG distribution.

I use boost::math::inverse_gaussian but it does not have an operator() member function like std::normal_distribution

Edit: Hörmann, W., Leydold have been doing some research into this topic:

  1. Paper Hörmann, W., Leydold, J. Generating generalized inverse Gaussian random variates. Stat Comput 24, 547–557 (2014). https://doi.org/10.1007/s11222-013-9387-3[https://doi.org/10.1007/s11222-013-9387-3][3]
  2. Slides UNU.RAN
  3. An Implementation in C Universal Non-Uniform RANdom number generators
1
see here: "Non-member Accessors - All the usual non-member accessor functions that are generic to all distributions are supported: ...."463035818_is_not_a_number
@463035818_is_not_a_number can you spell this out to me, please? I would like to get 100 numbers from the nig distribution boost docs for the non-member functions.Damian
Do I need a MC simulation to sample them?Damian
Looks like en.wikipedia.org/wiki/Inverse_Gaussian_distribution has a section about sampling which gives a simple algorithm.Robert Dodier

1 Answers

1
votes

I don't find the inverse Gaussian distribution in Boost.Random.

You can use the so-called inverse transform sampling technique. That is, you take the inverse cdf (i.e. the quantile function) of the inverse Gaussian distribution, and you apply it to a sample of uniformly random numbers in (0,1).

Something like that:

boost::math::inverse_gaussian my_ig(2, 3);
double inverseCDFig(double p){
  return boost::math::quantile(my_ig, p);
}

Then you use std::uniform_real_distribution to generate uniformly random numbers between 0 and 1, say u[i] for i = 0; i < N, and you compute inverseCDFig(u[i]) for every i. In this way you get a random sample from the inverse Gaussian distribution.