% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helper_functions.R
\name{rgig2}
\alias{rgig2}
\title{Generalized Inverse Gaussian Generator}
\usage{
rgig2(p, a, b)
}
\arguments{
\item{p}{a real valued parameter}

\item{a}{a non-negative parameter. If a=0, then p must be negative.}

\item{b}{a non-negative parameter. If b=0, then p must be positive.}
}
\value{
A numeric vector of random draws from the generalized inverse Gaussian distribution.
}
\description{
This function generates samples from the GIG(p, a, b) distribution with density function
f(x) = cx^(p-1)exp(-1/2*(a*x + b/x))
}
\details{
A uniformly bounded rejection sample based on Hörmann et. al. (2014). Special cases include Gamma (b=0, p>0), Inverse Gamma (a=0, p<0) and Inverse Gaussian (p=-1/2).
}
\examples{
x <- rep(NA, 1000)
for(i in 1:1000) x[i] <- rgig2(2, 3, 0.5)
hist(x)

}
\references{
Hörmann, Wolfgang, and Josef Leydold. "Generating generalized inverse Gaussian random variates." Statistics and Computing 24.4 (2014): 547-557.
}
