GIGrvg
Random Variate Generator for the GIG Distribution
Generator and density function for the Generalized Inverse Gaussian (GIG) distribution.
README
The GIG random number generator is implemented in C functions
'rgig' and 'do_rgig'.
They are exported and can be used in C code in other packages.
Here is an example of the usage of 'rgig' within a package
called "mypack".
For a description of 'do_rgig' the interested reader is
referred to its C code.
Differences to 'rgig' are:
(1) do_rgig() does not call GetRNGstate() and PutRNGstate(). You have
to take care of doing so in the function that calls do_rgig().
(2) Signature is SEXP do_rgig(int, double, double, double).
DESCRIPTION:
============
Depends: GIGrvg
LinkingTo: GIGrvg
C code:
=======
#include <Rinternals.h>
#include <R_ext/Rdynload.h>
#include <GIGrvg.h>
SEXP my_rgig (SEXP n, SEXP lambda, SEXP chi, SEXP psi)
{
SEXP (*fun)(SEXP,SEXP,SEXP,SEXP) = NULL;
if (!fun)
fun = (SEXP(*)(SEXP,SEXP,SEXP,SEXP)) R_GetCCallable("GIGrvg", "rgig");
return (fun(n,lambda,chi,psi));
}
R code:
=======
myrgig <- function(n=1, lambda, chi, psi) {
## ------------------------------------------------------------------------
## Generate GIG distributed random variates
##
## density proportional to
## f(x) = x^{lambda-1} e^{-1/2 (chi/x+psi x)}
##
## x >= 0
## ------------------------------------------------------------------------
## Arguments:
##
## n ....... sample size
## lambda .. parameter for distribution
## chi ... parameter for distribution
## psi ... parameter for distribution
## ------------------------------------------------------------------------
## generate sample
.Call("my_rgig", n, lambda, chi, psi, PACKAGE="mypack")
}
Versions across snapshots
| Version | Repository | File | Size |
|---|---|---|---|
0.8 |
rolling linux/jammy R-4.5 | GIGrvg_0.8.tar.gz |
23.9 KiB |
0.8 |
rolling linux/noble R-4.5 | GIGrvg_0.8.tar.gz |
23.9 KiB |
0.8 |
rolling source/ R- | GIGrvg_0.8.tar.gz |
23.0 KiB |
0.8 |
latest linux/jammy R-4.5 | GIGrvg_0.8.tar.gz |
23.9 KiB |
0.8 |
latest linux/noble R-4.5 | GIGrvg_0.8.tar.gz |
23.9 KiB |
0.8 |
latest source/ R- | GIGrvg_0.8.tar.gz |
23.0 KiB |
0.8 |
2026-04-26 source/ R- | GIGrvg_0.8.tar.gz |
23.0 KiB |
0.8 |
2026-04-23 source/ R- | GIGrvg_0.8.tar.gz |
23.0 KiB |
0.8 |
2026-04-09 windows/windows R-4.5 | GIGrvg_0.8.zip |
33.1 KiB |
0.8 |
2025-04-20 source/ R- | GIGrvg_0.8.tar.gz |
23.0 KiB |