Gig’s documentation¶
Draws from the Generalized Inverse Gaussian distribution
where \(\lambda\) is any real number, \(\chi\) must be nonnegative (nonpositive) for positive (negative) \(\lambda\) and \(\psi\) must be be nonnegative (nonpositive) for negative (positive) \(\lambda\).
Install¶
Download and unpack the latest version. In the unpacked folder, type
mkdir build
cd build
cmake ..
make
It should create the shared and static libraries
libgig.[version].[extension]
libgig_static.[extension]
You can enter
make test
to test it and
make install
to install it.
Usage example¶
Suppose you have the file
/* example.cpp */
#include "gig/gig.h"
#include <random>
#include <iostream>
int main()
{
Random random(1);
double lambda = 2.1;
double chi = 0.1;
double psi = 1.0;
std::cout << random.gig(lambda, chi, psi) << std::endl;
}
Compiling, linking, and running it via
g++ lgig example.cpp o example
./example
should print:
1.30869
Interface¶

class
Random
¶ Generalized Inverse Gaussian distribution sampler.

Random::
Random
(unsigned int seed)¶ Initialize sampler with a seed.
Parameters: seed – Seed.

Random::
Random
(std::default_random_engine &generator)¶ Initialize sampler with a random number generator.
Parameters: generator – Generator.

double
Random::
gig
(double lambda, double chi, double psi)¶ Draw sample from GIG distribution.
Parameters:  double lambda – shape parameter.
 double chi – shape and scale parameter.
 double psi – shape and scale parameter.
Returns: sample.

Disclaimer¶
This library is simply a wrapper around Josef Leydold and Wolfgang Hormann’s implementation of a GIG sampler found in the GIGrvg package.