Skip to contents

Scalar inverse Gaussian utilities under the \((\mu, \lambda)\) parameterization, where mean = mu > 0 and shape = lambda > 0. These functions are used directly and as building blocks for inverse-Gaussian mixtures and spliced inverse-Gaussian-plus-GPD families.

Usage

dInvGauss(x, mean, shape, log = 0)

pInvGauss(q, mean, shape, lower.tail = 1, log.p = 0)

rInvGauss(n, mean, shape)

qInvGauss(
  p,
  mean,
  shape,
  lower.tail = TRUE,
  log.p = FALSE,
  tol = 1e-10,
  maxiter = 200
)

Arguments

x

Numeric scalar giving the point at which the density is evaluated.

mean

Numeric scalar mean parameter \(\mu>0\).

shape

Numeric scalar shape parameter \(\lambda>0\).

log

Logical; if TRUE, return the log-density (integer flag 0/1 in NIMBLE).

q

Numeric scalar giving the point at which the distribution function is evaluated.

lower.tail

Logical; if TRUE (default), probabilities are \(P(X \le q)\).

log.p

Logical; if TRUE, probabilities are returned on the log scale.

n

Integer giving the number of draws. For portability inside NIMBLE, the RNG implementation supports n = 1.

p

Numeric scalar giving the probability for the quantile.

tol

Numeric scalar tolerance passed to stats::uniroot.

maxiter

Integer maximum number of iterations for stats::uniroot.

Value

dInvGauss() returns a numeric scalar density, pInvGauss() returns a numeric scalar CDF, rInvGauss() returns one random draw, and qInvGauss() returns a numeric quantile.

Details

The density is $$ f(x) = \left(\frac{\lambda}{2 \pi x^3}\right)^{1/2} \exp\left\{- \frac{\lambda (x - \mu)^2}{2 \mu^2 x}\right\}, \qquad x > 0. $$

These uppercase NIMBLE-compatible functions are scalar (x/q and n = 1). For vectorized R usage, use base_lowercase().

The inverse Gaussian is the first-passage-time distribution of a Brownian motion with positive drift. Under the \((\mu, \lambda)\) parameterization used here, the mean is \(E(X)=\mu\) and the variance is \(\mathrm{Var}(X)=\mu^3/\lambda\). The implementation follows that parameterization throughout the package, so inverse-Gaussian mixture and splice families inherit the same interpretation.

The distribution function is evaluated through the standard normal representation $$ F(x) = \Phi\left(\sqrt{\frac{\lambda}{x}}\left(\frac{x}{\mu}-1\right)\right) + \exp\left(\frac{2\lambda}{\mu}\right) \Phi\left(-\sqrt{\frac{\lambda}{x}}\left(\frac{x}{\mu}+1\right)\right), $$ and the quantile is obtained numerically because no simple closed form is available.

Functions

  • dInvGauss(): Inverse Gaussian density function

  • pInvGauss(): Inverse Gaussian distribution function

  • rInvGauss(): Inverse Gaussian random generation

  • qInvGauss(): Inverse Gaussian quantile function

See also

Examples

mean <- 2
shape <- 5

dInvGauss(2.0, mean, shape, log = 0)
#> [1] 0.3153916
pInvGauss(2.0, mean, shape, lower.tail = 1, log.p = 0)
#> [1] 0.6161631
qInvGauss(0.50, mean, shape)
#> [1] 1.673117
qInvGauss(0.95, mean, shape)
#> [1] 4.458125
replicate(10, rInvGauss(1, mean, shape))
#>  [1] 2.4309903 3.4258917 1.2209535 1.4736911 2.3957903 0.8260154 3.6687637
#>  [8] 2.3261192 3.2370549 1.3304050