% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distributions.R
\name{nig}
\alias{nig}
\alias{dnig}
\alias{rnig}
\alias{pnig}
\alias{qnig}
\title{The Normal Inverse-Gaussian (NIG) Distribution}
\usage{
dnig(x, delta, mu, nu, sigma, h = NULL, log = FALSE)

rnig(n, delta, mu, nu, sigma, h = NULL, seed = 0)

pnig(q, delta, mu, nu, sigma, h = NULL, lower.tail = TRUE, log.p = FALSE)

qnig(p, delta, mu, nu, sigma, h = NULL, lower.tail = TRUE, log.p = FALSE)
}
\arguments{
\item{x, q}{vector of quantiles.}

\item{delta}{A numeric value for the location parameter.}

\item{mu}{A numeric value for the shift parameter.}

\item{nu}{A numeric value for the shape parameter.}

\item{sigma}{A numeric value for the scaling parameter.}

\item{h}{A numeric value for the additional parameter, see details.}

\item{log, log.p}{logical; if \code{TRUE}, probabilities/densities \eqn{p} are
returned as \eqn{log(p)}.}

\item{n, }{number of observations.}

\item{seed}{Seed for the random generation.}

\item{lower.tail}{logical; if \code{TRUE}, probabilities are \eqn{P[X\leq x]},
otherwise, \eqn{P[X>x]}.}

\item{p}{vector of probabilities.}
}
\value{
dnig gives the density, pnig gives the distribution function,
qnig gives the quantile function, and rnig generates random deviates.

Invalid arguments will result in return value NaN, with a warning.

The length of the result is determined by \code{n} for rnig.
}
\description{
Density, distribution function, quantile function and
random generation for the normal inverse-Gaussian distribution
 with parameters \code{p}, \code{a} and \code{b}.
}
\details{
The normal inverse-Gaussian distribution has density given
by
 \deqn{f(x; \delta, \mu, \sigma, \nu) =
 \frac{e^{\nu+\mu(x-\delta)/\sigma^2}\sqrt{\nu\mu^2/\sigma^2+\nu^2}}{\pi\sqrt{\nu\sigma^2+(x-\delta)^2}}
 K_1(\sqrt{(\nu\sigma^2+(x-\delta)^2)(\mu^2/\sigma^4+\nu/\sigma^2)}),}
 where \eqn{K_p} is modified Bessel function of the second kind of order \eqn{p},
 \eqn{x>0}, \eqn{\nu>0} and \eqn{\mu,\delta, \sigma\in\mathbb{R}}.
 See Barndorff-Nielsen (1977, 1978 and 1997) for further details.

The additional parameter h is used when \deqn{V\sim IG(\nu,\nu h^{2})}.
By the infinite divisibility, \deqn{\frac{1}{h} V \sim IG(\nu h, \nu h)}.
Then \deqn{\delta+\mu V + \sigma \sqrt{V} Z} has the distribution of \deqn{NIG(\delta=-\mu h,\mu= \mu h, \sigma=\sigma \sqrt{h}, \nu=\nu h).}
}
\examples{
rnig(100, delta = 0, mu = 5, sigma = 1, nu = 1)
pnig(0.4, delta = 0, mu = 5, sigma = 1, nu = 1)
qnig(0.8, delta = 0, mu = 5, sigma = 1, nu = 1)
plot(function(x){dnig(x, delta = 0, mu = 5, sigma = 1, nu = 1)}, main =
"Normal inverse-Gaussian density", ylab = "Probability density",
xlim = c(0,10))
}
\references{
Barndorff-Nielsen, O. (1977) Exponentially decreasing distributions for the logarithm of particle size. Proceedings of the Royal Society of London.

 Series A, Mathematical and Physical Sciences. The Royal Society. 353, 401–409. \doi{10.1098/rspa.1977.0041}

 Barndorff-Nielsen, O. (1978) Hyperbolic Distributions and Distributions on Hyperbolae, Scandinavian Journal of Statistics. 5, 151–157.

 Barndorff-Nielsen, O. (1997) Normal Inverse Gaussian Distributions and Stochastic Volatility Modelling, Scandinavian Journal of Statistics. 24, 1-13. \doi{10.1111/1467-9469.00045}
}
\seealso{
\code{\link{dgig}}, \code{\link{dig}}, \code{\link{digam}}
}
