% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gal.R
\name{gal}
\alias{gal}
\alias{dgal}
\alias{rgal}
\alias{pgal}
\alias{qgal}
\title{The Generalized Asymmetric Laplace (GAL) Distribution}
\usage{
dgal(x, delta, mu, nu, sigma, log = FALSE)

rgal(n, delta, mu, nu, sigma, seed = 0)

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

qgal(p, delta, mu, nu, sigma, 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{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{
dgal gives the density, pgal gives the distribution function,
qgal gives the quantile function, and rgal 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 rgal.
}
\description{
Density, distribution function, quantile function and
random generation for the generalized asymmetric Laplace distribution
 with parameters \code{mu}, \code{sigma} and \code{nu}, \code{delta}.
}
\details{
The generalized asymmetric Laplace distribution has density given
by
 \deqn{f(x; p, a, b) =
 \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.

If the mixing variable \eqn{V} follows a Gamma distribution (same parameterization in R):
\deqn{V \sim \Gamma(h \nu, \nu),} then the poserior follows the GAL distribution (a special case of GIG distribution):
\deqn{
-\mu +\mu V + \sigma \sqrt{V} Z \sim GIG(h \nu - 0.5, 2 \nu + (\frac{\mu}{\sigma})^{2}, 0)
}
}
\examples{
rgal(100, delta = 0, mu = 5, sigma = 1, nu = 1)
pgal(0.4, delta = 0, mu = 5, sigma = 1, nu = 1)
qgal(0.8, delta = 0, mu = 5, sigma = 1, nu = 1)
plot(function(x){dgal(x, delta = 0, mu = 5, sigma = 1, nu = 1)}, main =
"generalized asymmetric Laplace 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.
}
\seealso{
\code{\link{dgig}}, \code{\link{dig}}, \code{\link{digam}}
}
