% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/invgauss.R
\name{InvGauss_mix}
\alias{InvGauss_mix}
\alias{dInvGaussMix}
\alias{pInvGaussMix}
\alias{rInvGaussMix}
\alias{qInvGaussMix}
\title{Inverse Gaussian mixture distribution}
\usage{
dInvGaussMix(x, w, mean, shape, log = 0)

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

rInvGaussMix(n, w, mean, shape)

qInvGaussMix(
  p,
  w,
  mean,
  shape,
  lower.tail = TRUE,
  log.p = FALSE,
  tol = 1e-10,
  maxiter = 200
)
}
\arguments{
\item{x}{Numeric scalar giving the point at which the density is evaluated.}

\item{w}{Numeric vector of mixture weights of length \eqn{K}. The functions normalize \code{w}
internally when needed.}

\item{mean, shape}{Numeric vectors of length \eqn{K} giving component means and shapes.}

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

\item{q}{Numeric scalar giving the point at which the distribution function is evaluated.}

\item{lower.tail}{Logical; if \code{TRUE} (default), probabilities are \eqn{P(X \le q)}.}

\item{log.p}{Logical; if \code{TRUE}, probabilities are returned on the log scale.}

\item{n}{Integer giving the number of draws. For portability inside NIMBLE,
the RNG implementation supports \code{n = 1}.}

\item{p}{Numeric scalar probability in \eqn{(0,1)} for the quantile function.}

\item{tol}{Numeric scalar tolerance passed to \code{stats::uniroot} in quantile inversion.}

\item{maxiter}{Integer maximum number of iterations for \code{stats::uniroot}.}
}
\value{
Density/CDF/RNG functions return numeric scalars. \code{qInvGaussMix()} returns a numeric
vector with the same length as \code{p}.
}
\description{
Finite mixture of inverse Gaussian components for positive-support bulk modeling. Each component
is parameterized by \code{mean[j]} and \code{shape[j]}.
}
\details{
The scalar functions in this topic are the compiled building blocks for inverse-Gaussian bulk
kernels. For vectorized R usage, use \code{\link[=invgauss_lowercase]{invgauss_lowercase()}}.

The mixture distribution is
\deqn{
F(x) = \sum_{k=1}^K \tilde{w}_k F_{IG}(x \mid \mu_k,\lambda_k),
}
where each inverse Gaussian component has mean \eqn{\mu_k} and variance \eqn{\mu_k^3/\lambda_k}.
Random generation selects a component using the normalized weights and then generates from the
corresponding inverse Gaussian law. Quantiles are computed numerically because the finite-mixture
inverse CDF is not available in closed form.

The analytical mixture mean is
\deqn{
E(X) = \sum_{k=1}^K \tilde{w}_k \mu_k.
}
That expression is used by the package whenever inverse-Gaussian mixtures contribute to
posterior predictive means.
}
\section{Functions}{
\itemize{
\item \code{dInvGaussMix()}: Inverse Gaussian mixture density

\item \code{pInvGaussMix()}: Inverse Gaussian mixture distribution function

\item \code{rInvGaussMix()}: Inverse Gaussian mixture random generation

\item \code{qInvGaussMix()}: Inverse Gaussian mixture quantile function

}}
\examples{
w <- c(0.55, 0.30, 0.15)
mean <- c(1.0, 2.5, 5.0)
shape <- c(2, 4, 8)

dInvGaussMix(2.0, w = w, mean = mean, shape = shape, log = 0)
pInvGaussMix(2.0, w = w, mean = mean, shape = shape,
            lower.tail = 1, log.p = 0)
qInvGaussMix(0.50, w = w, mean = mean, shape = shape)
qInvGaussMix(0.95, w = w, mean = mean, shape = shape)
replicate(10, rInvGaussMix(1, w = w, mean = mean, shape = shape))
}
\seealso{
\code{\link[=InvGauss_mixgpd]{InvGauss_mixgpd()}}, \code{\link[=InvGauss_gpd]{InvGauss_gpd()}}, \code{\link[=invgauss_lowercase]{invgauss_lowercase()}},
\code{\link[=build_nimble_bundle]{build_nimble_bundle()}}, \code{\link[=kernel_support_table]{kernel_support_table()}}.

Other inverse-gaussian kernel families: 
\code{\link{InvGauss_gpd}},
\code{\link{InvGauss_mixgpd}}
}
\concept{inverse-gaussian kernel families}
