% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_spec.R
\name{dist_spec}
\alias{dist_spec}
\title{Define a univariate distribution for simulation}
\usage{
dist_spec(
  d = NULL,
  p = NULL,
  q = NULL,
  surv = NULL,
  lower = 0,
  upper = Inf,
  param = list(),
  name = "custom"
)
}
\arguments{
\item{d}{function; PDF \eqn{f(x, \theta)}.}

\item{p}{function; CDF \eqn{F(x, \theta)}.}

\item{q}{function; quantile function \eqn{F^{-1}(u, \theta)}.}

\item{surv}{function; survival function \eqn{S(x, \theta)}.}

\item{lower}{numeric; lower support bound (default \code{0}).}

\item{upper}{numeric; upper support bound (default \code{Inf}).}

\item{param}{named list of distribution parameters (default empty).}

\item{name}{character label for plots (default \code{"custom"}).}
}
\value{
An object of class \code{"dist_spec"}, which is a list with
elements \code{d}, \code{p}, \code{q}, \code{surv} (user-supplied
functions or \code{NULL}), \code{lower} and \code{upper} (support
bounds), \code{param} (named list of parameters), and \code{name}
(character label).
}
\description{
Creates a reusable distribution specification passed to all
\pkg{UniCensor} sampling functions.  At least one of \code{q},
\code{surv}, \code{p}, or \code{d} must be supplied for random
number generation via inverse transform sampling.
}
\examples{
# Exponential(rate = 1)
exp_dist <- dist_spec(
  d    = function(x, p) p$rate * exp(-p$rate * x),
  p    = function(x, p) 1 - exp(-p$rate * x),
  q    = function(u, p) -log(1 - u) / p$rate,
  surv = function(x, p) exp(-p$rate * x),
  lower = 0, upper = Inf,
  param = list(rate = 1),
  name  = "Exp(1)"
)
}
