R/rgig.R

Defines functions dgig rgig

Documented in dgig rgig

rgig <- 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(C_rgig, n, lambda, chi, psi)
}

dgig <- function(x, lambda, chi, psi, log = FALSE) {
  ## ------------------------------------------------------------------------
  ## 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
  ##   log   ... if TRUE the logarithm of the density will be returned
  ## ------------------------------------------------------------------------

  ## generate sample
  .Call(C_dgig, x, lambda, chi, psi, log)
}

Try the GIGrvg package in your browser

Any scripts or data that you put into this service are public.

GIGrvg documentation built on March 31, 2023, 11:39 p.m.