% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cold_standby.R
\name{cold_standby_dist}
\alias{cold_standby_dist}
\alias{sampler.cold_standby_dist}
\alias{surv.cold_standby_dist}
\alias{cdf.cold_standby_dist}
\title{Cold-standby system distribution}
\usage{
cold_standby_dist(components)

\method{sampler}{cold_standby_dist}(x, ...)

\method{surv}{cold_standby_dist}(x, ...)

\method{cdf}{cold_standby_dist}(x, ...)
}
\arguments{
\item{components}{List of \code{dist} objects representing per-stage
component lifetimes.}

\item{x}{A \code{cold_standby_dist} object.}

\item{...}{Ignored.}
}
\value{
An object of class
\code{c("cold_standby_dist", "univariate_dist", "continuous_dist", "dist")}.
}
\description{
Constructs a distribution representing a cold-standby system: one
component active at a time with perfect, instantaneous switching to
the next spare upon failure. System lifetime equals the sum of
independent component lifetimes.

Estimates \code{S(t) = P(T_1 + ... + T_m > t)} by simulating \code{mc} system
lifetimes and computing the empirical fraction exceeding \code{t}. The
returned closure caches its sample vector: the first call generates
\code{mc} samples, subsequent calls reuse them as long as \code{mc} is
unchanged (a different \code{mc} triggers a fresh draw). This makes
repeated \code{S(t)} calls deterministic given the same \code{mc}.

Computes the CDF by deferring to a fresh \code{surv} closure. The CDF
closure has its own sample cache (independent of any external \code{surv}
closure), so \code{cdf(x)(t) + surv(x)(t)} is generally not exactly 1
unless callers reuse a single \code{surv} closure: prefer
\verb{S <- surv(x); F_t <- 1 - S(t)} over computing both independently.
}
\details{
Cold standby is not a coherent system in the structure-function sense
(its topology is temporal succession, not an order statistic), so the
returned object does not inherit \code{dist_structure}. It IS a \code{dist}
(with \code{surv}, \code{cdf}, \code{sampler}, \code{mean} available) and exposes
\code{\link[=ncomponents]{ncomponents()}} and \code{\link[=component]{component()}} for inspection.

Defaults: \code{sampler} is exact (sample each component independently and
sum); \code{mean} is exact when every component implements \code{mean()}
(otherwise falls back to Monte Carlo via the sampler); \code{surv} and
\code{cdf} use Monte Carlo with a default of \code{1e5} simulated lifetimes
(override via the \code{mc} argument). The returned \code{surv} / \code{cdf}
closures cache their samples after the first call so subsequent
evaluations at different \code{t} values are deterministic given the same
\code{mc}.

Methods inherited from \code{algebraic.dist::univariate_dist} that require
\code{density} or \code{sup} (notably \code{expectation}, \code{vcov}) are NOT supported
on cold-standby objects out of the box; specialized subclasses with
closed-form aggregate distributions (e.g., iid exponential collapses
to \code{Gamma(m, rate)}) should provide their own methods.

For reproducibility across calls to \code{surv()} itself (i.e., between
separately constructed closures), set the RNG seed externally via
\code{set.seed()} before invoking \code{surv(x)}. Override the method on a
subclass with an exact aggregate distribution (e.g., iid exponential
collapses to \code{Gamma(m, rate)}) when an analytic form is available.
}
\examples{
# Cold standby of 3 iid Exp(1) components: aggregate is Gamma(3, 1)
sys <- cold_standby_dist(replicate(3,
  algebraic.dist::exponential(1), simplify = FALSE))
mean(sys)  # = 3
}
