| Title: | Structured Random Variables for Reliability System Distributions |
|---|---|
| Description: | Extends the 'algebraic.dist' distribution algebra to random variables with internal structure: coherent reliability systems decomposed into components arranged by a structure function (series, parallel, k-out-of-n, bridge, and arbitrary topologies via minimal path sets). Every 'dist_structure' object is a 'dist', so the full distribution algebra (mean, vcov, sampler, surv, cdf) works automatically via default methods that compose component-level distributions through the topology. Adds structural queries: structure function evaluation, minimal path and cut sets, system signature, critical states, dual, Birnbaum structural importance, and system reliability. Topology shortcut constructors (series_dist, parallel_dist, kofn_dist, bridge_dist) produce ready-to-use dists from component dists and a chosen structure. |
| Authors: | Alexander Towell [aut, cre] (ORCID: <https://orcid.org/0000-0001-6443-9897>) |
| Maintainer: | Alexander Towell <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.5.0 |
| Built: | 2026-05-12 21:26:44 UTC |
| Source: | https://github.com/cran/dist.structure |
Wraps a plain algebraic.dist distribution in a 1-component series_dist
so that it satisfies the dist_structure protocol. Useful for
polymorphic code that operates on dist_structure inputs but is also
handed unwrapped distributions. A dist_structure is returned
unchanged.
## S3 method for class 'dist_structure' as_dist_structure(x, ...) ## S3 method for class 'dist' as_dist_structure(x, ...) as_dist_structure(x, ...)## S3 method for class 'dist_structure' as_dist_structure(x, ...) ## S3 method for class 'dist' as_dist_structure(x, ...) as_dist_structure(x, ...)
x |
A dist or dist_structure. |
... |
Reserved for methods. |
A dist_structure object.
The Birnbaum importance of component j at component reliabilities
p is dR/dp_j = R(p with p_j = 1) - R(p with p_j = 0). Measures
how much the system reliability changes if j moves between certain
failure and certain success (and, by monotonicity, the rate of
change at any intermediate p_j).
birnbaum_importance(x, j, p) ## S3 method for class 'dist_structure' birnbaum_importance(x, j, p)birnbaum_importance(x, j, p) ## S3 method for class 'dist_structure' birnbaum_importance(x, j, p)
x |
A dist_structure object. |
j |
Component index. |
p |
Numeric vector of length |
Numeric scalar in [0, 1].
The classical 5-component bridge reliability network with minimal
path sets {1,4}, {2,5}, {1,3,5}, {2,3,4}. Components 1 and 2
are the input side, 4 and 5 the output side, and 3 the cross-link.
The bridge is a canonical non-series, non-parallel example used
throughout the reliability literature; see Barlow and Proschan (1975,
"Statistical Theory of Reliability and Life Testing") for the
standard treatment.
bridge_dist(components)bridge_dist(components)
components |
List of 5 |
A bridge_dist inheriting from coherent_dist.
General-purpose constructor. Users supply a list of minimal path sets
(each a vector of component indices) and a list of component
distributions (each an algebraic.dist::dist object with parameters
baked in). The resulting object is a dist_structure and dist.
coherent_dist(min_paths, components, m = NULL)coherent_dist(min_paths, components, m = NULL)
min_paths |
List of integer vectors; each is a minimal path set. |
components |
List of |
m |
Optional integer. Inferred from |
An object of class
c("coherent_dist", "dist_structure", "univariate_dist", "dist").
# A bridge network with exponential components sys <- coherent_dist( min_paths = list(c(1, 4), c(2, 5), c(1, 3, 5), c(2, 3, 4)), components = replicate(5, algebraic.dist::exponential(1), simplify = FALSE) ) reliability(sys, 0.9)# A bridge network with exponential components sys <- coherent_dist( min_paths = list(c(1, 4), c(2, 5), c(1, 3, 5), c(2, 3, 4)), components = replicate(5, algebraic.dist::exponential(1), simplify = FALSE) ) reliability(sys, 0.9)
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 S(t) = P(T_1 + ... + T_m > t) by simulating mc system
lifetimes and computing the empirical fraction exceeding t. The
returned closure caches its sample vector: the first call generates
mc samples, subsequent calls reuse them as long as mc is
unchanged (a different mc triggers a fresh draw). This makes
repeated S(t) calls deterministic given the same mc.
Computes the CDF by deferring to a fresh surv closure. The CDF
closure has its own sample cache (independent of any external surv
closure), so cdf(x)(t) + surv(x)(t) is generally not exactly 1
unless callers reuse a single surv closure: prefer
S <- surv(x); F_t <- 1 - S(t) over computing both independently.
cold_standby_dist(components) ## S3 method for class 'cold_standby_dist' sampler(x, ...) ## S3 method for class 'cold_standby_dist' surv(x, ...) ## S3 method for class 'cold_standby_dist' cdf(x, ...)cold_standby_dist(components) ## S3 method for class 'cold_standby_dist' sampler(x, ...) ## S3 method for class 'cold_standby_dist' surv(x, ...) ## S3 method for class 'cold_standby_dist' cdf(x, ...)
components |
List of |
x |
A |
... |
Ignored. |
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 dist_structure. It IS a dist
(with surv, cdf, sampler, mean available) and exposes
ncomponents() and component() for inspection.
Defaults: sampler is exact (sample each component independently and
sum); mean is exact when every component implements mean()
(otherwise falls back to Monte Carlo via the sampler); surv and
cdf use Monte Carlo with a default of 1e5 simulated lifetimes
(override via the mc argument). The returned surv / cdf
closures cache their samples after the first call so subsequent
evaluations at different t values are deterministic given the same
mc.
Methods inherited from algebraic.dist::univariate_dist that require
density or sup (notably expectation, 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 Gamma(m, rate)) should provide their own methods.
For reproducibility across calls to surv() itself (i.e., between
separately constructed closures), set the RNG seed externally via
set.seed() before invoking surv(x). Override the method on a
subclass with an exact aggregate distribution (e.g., iid exponential
collapses to Gamma(m, rate)) when an analytic form is available.
An object of class
c("cold_standby_dist", "univariate_dist", "continuous_dist", "dist").
# 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# 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
Returns the j-th component as an algebraic.dist::dist object with
parameters baked in (so sampler, surv, etc. work directly on it).
component(x, j, ...)component(x, j, ...)
x |
A dist_structure object. |
j |
Integer component index in |
... |
Implementation-specific arguments (e.g., parameter overrides for lazily parameterized systems). |
An object inheriting from dist.
Produce a new dist_structure by replacing each component of outer
with a sub-system (either a dist_structure or a plain dist). The
composed system's components are the flattened inner components; its
min_paths enumerate the Cartesian products of inner min_paths within
each outer min_path.
## S3 method for class 'dist_structure' compose_systems(outer, inner_list) compose_systems(outer, inner_list)## S3 method for class 'dist_structure' compose_systems(outer, inner_list) compose_systems(outer, inner_list)
outer |
A dist_structure object. |
inner_list |
A list of length |
Computational note: the composed minimal-path enumeration takes the
Cartesian product of inner-path choices over each outer path. For an
outer system with p paths each of length q, where each inner has
r paths, the candidate count grows as O(p * r^q) before
deduplication. Bridge-of-bridges and similar deeply nested
compositions can produce hundreds of candidates; if you find the call
slow, build the composed coherent_dist directly with a hand-curated
min_paths list.
A coherent_dist representing the composed system.
The consecutive-k-out-of-n:G system functions when at least one block
of k consecutive components all function. Minimal path sets are the
n - k + 1 consecutive blocks of size k. (Note: this is the :G
variant; the :F variant, "fails when any k consecutive fail", has
different minimal paths.)
consecutive_k_dist(k, components)consecutive_k_dist(k, components)
k |
Block size. |
components |
List of |
A consecutive_k_dist inheriting from coherent_dist.
Critical states of a component
## S3 method for class 'dist_structure' critical_states(x, j) critical_states(x, j)## S3 method for class 'dist_structure' critical_states(x, j) critical_states(x, j)
x |
A dist_structure object. |
j |
Component index. |
Integer matrix with m - 1 columns; rows are the states of the
other components for which j is critical.
Probability that component j has failed AND is critical given
that the system has failed by time t. Equals
I_B(j; S(t)) * F_j(t) / F_sys(t).
criticality_importance(x, j, t) ## S3 method for class 'dist_structure' criticality_importance(x, j, t)criticality_importance(x, j, t) ## S3 method for class 'dist_structure' criticality_importance(x, j, t)
x |
A dist_structure object. |
j |
Component index. |
t |
Scalar time. |
Numeric scalar in [0, 1].
Overrides the lazy-wrapper default with a proper coherent_dist:
min_paths(dual(x)) = min_cuts(x).
Returns a dual_of_system object carrying the original structure.
phi_dual(state) = 1 - phi(original, 1 - state) is evaluated on demand.
All other generics fall through to dist_structure defaults.
The dual structure satisfies phi_dual(state) = 1 - phi(1 - state). The
dual of a series system is parallel; the dual of k-out-of-n is
(n - k + 1)-out-of-n.
## S3 method for class 'coherent_dist' dual(x) ## S3 method for class 'dist_structure' dual(x) ## S3 method for class 'dual_of_system' dual(x) dual(x)## S3 method for class 'coherent_dist' dual(x) ## S3 method for class 'dist_structure' dual(x) ## S3 method for class 'dual_of_system' dual(x) dual(x)
x |
A dist_structure object. |
A dist_structure object representing the dual.
Constructs a dist_structure for a k-out-of-m system whose components
are independent exponentials. Closed-form methods are provided for
surv, cdf, sampler, density, and hazard. mean falls back
to numerical integration via the dist_structure default.
exp_kofn(k, rates) ## S3 method for class 'exp_kofn' surv(x, ...) ## S3 method for class 'exp_kofn' sampler(x, ...) ## S3 method for class 'exp_kofn' hazard(x, ...) ## S3 method for class 'exp_kofn' density(x, ...)exp_kofn(k, rates) ## S3 method for class 'exp_kofn' surv(x, ...) ## S3 method for class 'exp_kofn' sampler(x, ...) ## S3 method for class 'exp_kofn' hazard(x, ...) ## S3 method for class 'exp_kofn' density(x, ...)
k |
Minimum number of functioning components for system operation. |
rates |
Positive numeric vector of length |
x |
An |
... |
Ignored. |
exp_kofn() returns an object of class
c("exp_kofn", "kofn_dist", "coherent_dist", "dist_structure", "univariate_dist", "continuous_dist", "dist").
The associated S3 methods return:
surv(), density(), hazard(): a closure function(t, ...).
cdf() is derived via the dist_structure default and returns
a closure function(t, ...) equal to 1 - surv(x)(t).
sampler(): a closure function(n, ...) returning n random
variates from the system lifetime distribution.
sys <- exp_kofn(k = 2, rates = c(1, 2, 3)) algebraic.dist::surv(sys)(1)sys <- exp_kofn(k = 2, rates = c(1, 2, 3)) algebraic.dist::surv(sys)(1)
Constructs a dist_structure representing a parallel system whose
components are independent exponentials. Closed-form methods are
provided for surv, cdf, sampler, and mean (the last via
inclusion-exclusion over the 2^m - 1 non-empty component subsets).
exp_parallel(rates) ## S3 method for class 'exp_parallel' surv(x, ...) ## S3 method for class 'exp_parallel' sampler(x, ...) ## S3 method for class 'exp_parallel' mean(x, ...)exp_parallel(rates) ## S3 method for class 'exp_parallel' surv(x, ...) ## S3 method for class 'exp_parallel' sampler(x, ...) ## S3 method for class 'exp_parallel' mean(x, ...)
rates |
Positive numeric vector of length |
x |
An |
... |
Ignored. |
exp_parallel() returns an object of class
c("exp_parallel", "parallel_dist", "coherent_dist", "dist_structure", "univariate_dist", "continuous_dist", "dist").
The associated S3 methods return:
surv(): a closure function(t, ...).
cdf() is derived via the dist_structure default and returns
a closure function(t, ...) equal to 1 - surv(x)(t).
sampler(): a closure function(n, ...) returning n random
variates from the system lifetime distribution.
mean(): a numeric scalar (the mean system lifetime,
computed in closed form via inclusion-exclusion).
sys <- exp_parallel(c(1, 2, 3)) algebraic.dist::surv(sys)(1)sys <- exp_parallel(c(1, 2, 3)) algebraic.dist::surv(sys)(1)
Constructs a dist_structure representing a series system whose
components are independent exponentials. The system lifetime is itself
an Exp(sum(rates)) distribution; all dist-level queries have
closed-form expressions that bypass the general default methods.
exp_series(rates) ## S3 method for class 'exp_series' surv(x, ...) ## S3 method for class 'exp_series' sampler(x, ...) ## S3 method for class 'exp_series' mean(x, ...) ## S3 method for class 'exp_series' density(x, ...) ## S3 method for class 'exp_series' hazard(x, ...)exp_series(rates) ## S3 method for class 'exp_series' surv(x, ...) ## S3 method for class 'exp_series' sampler(x, ...) ## S3 method for class 'exp_series' mean(x, ...) ## S3 method for class 'exp_series' density(x, ...) ## S3 method for class 'exp_series' hazard(x, ...)
rates |
Positive numeric vector of length |
x |
An |
... |
Ignored. |
exp_series() returns an object of class
c("exp_series", "series_dist", "coherent_dist", "dist_structure", "univariate_dist", "continuous_dist", "dist").
The associated S3 methods return:
surv(), density(), hazard(): a closure function(t, ...)
evaluating the named quantity at t.
cdf() is derived via the dist_structure default and returns
a closure function(t, ...) equal to 1 - surv(x)(t).
sampler(): a closure function(n, ...) returning n random
variates from the system lifetime distribution.
mean(): a numeric scalar (the mean system lifetime).
sys <- exp_series(c(0.5, 0.3, 0.2)) algebraic.dist::surv(sys)(1) # equals exp(-sum(rates) * 1) mean(sys) # equals 1 / sum(rates)sys <- exp_series(c(0.5, 0.3, 0.2)) algebraic.dist::surv(sys)(1) # equals exp(-sum(rates) * 1) mean(sys) # equals 1 / sum(rates)
Format a dist_structure object
## S3 method for class 'dist_structure' format(x, ...)## S3 method for class 'dist_structure' format(x, ...)
x |
A dist_structure object. |
... |
Ignored. |
Character vector suitable for cat().
Constructs a dist_structure for a series system whose components are
independent Gammas. Closed-form surv is evaluated by the product of
per-component upper-tail probabilities; cdf is 1 - surv; sampler
generates m independent Gammas and takes the min.
gamma_series(shapes, rates) ## S3 method for class 'gamma_series' surv(x, ...) ## S3 method for class 'gamma_series' sampler(x, ...)gamma_series(shapes, rates) ## S3 method for class 'gamma_series' surv(x, ...) ## S3 method for class 'gamma_series' sampler(x, ...)
shapes |
Positive numeric vector of length |
rates |
Positive numeric vector of length |
x |
A |
... |
Ignored. |
gamma_series() returns an object of class
c("gamma_series", "series_dist", "coherent_dist", "dist_structure", "univariate_dist", "continuous_dist", "dist").
The associated S3 methods return:
surv(): a closure function(t, ...).
cdf() is derived via the dist_structure default and returns
a closure function(t, ...) equal to 1 - surv(x)(t).
sampler(): a closure function(n, ...) returning n random
variates from the system lifetime distribution.
sys <- gamma_series(shapes = c(2, 3), rates = c(1, 2)) algebraic.dist::surv(sys)(1)sys <- gamma_series(shapes = c(2, 3), rates = c(1, 2)) algebraic.dist::surv(sys)(1)
Coherence axiom check
## S3 method for class 'dist_structure' is_coherent(x) is_coherent(x)## S3 method for class 'dist_structure' is_coherent(x) is_coherent(x)
x |
A dist_structure object. |
TRUE if monotone and every component relevant.
Predicate for dist_structure objects
is_dist_structure(x)is_dist_structure(x)
x |
Any object. |
TRUE if x inherits from "dist_structure".
A k-out-of-n system functions if at least k of its m components
function. Equivalent to the (m - k + 1)-th order statistic of
component lifetimes.
kofn_dist(k, components)kofn_dist(k, components)
k |
Minimum functioning components for system operation (:G). |
components |
List of |
This constructor uses the :G convention: k is the number of
components that must remain functioning for the system to function.
k = 1 is parallel; k = m is series. The companion kofn package
(which depends on dist.structure) uses the :F convention, where
k is the number of failures that trigger system failure; conversion
is k_dist = m - k_kofn + 1. When in doubt, draw a small example:
kofn_dist(k = 2, ...) for m = 3 functions until two of the three
components have failed.
A kofn_dist inheriting from coherent_dist.
order_statistic() for the closely-related order-statistic
parameterization.
Constructs a dist_structure for a series system whose components are
independent Lognormals. Closed-form surv is the product of
per-component upper-tail probabilities; cdf is 1 - surv; sampler
generates m independent Lognormals and takes the min.
lognormal_series(meanlogs, sdlogs) ## S3 method for class 'lognormal_series' surv(x, ...) ## S3 method for class 'lognormal_series' sampler(x, ...)lognormal_series(meanlogs, sdlogs) ## S3 method for class 'lognormal_series' surv(x, ...) ## S3 method for class 'lognormal_series' sampler(x, ...)
meanlogs |
Numeric vector of length |
sdlogs |
Positive numeric vector of length |
x |
A |
... |
Ignored. |
lognormal_series() returns an object of class
c("lognormal_series", "series_dist", "coherent_dist", "dist_structure", "univariate_dist", "continuous_dist", "dist").
The associated S3 methods return:
surv(): a closure function(t, ...).
cdf() is derived via the dist_structure default and returns
a closure function(t, ...) equal to 1 - surv(x)(t).
sampler(): a closure function(n, ...) returning n random
variates from the system lifetime distribution.
sys <- lognormal_series(meanlogs = c(0, 1), sdlogs = c(1, 0.5)) algebraic.dist::surv(sys)(1)sys <- lognormal_series(meanlogs = c(0, 1), sdlogs = c(1, 0.5)) algebraic.dist::surv(sys)(1)
Equivalent to the maximum of m iid random variables from d.
Preserves the parallel topology for structural queries.
max_iid(d, m)max_iid(d, m)
d |
A |
m |
Number of components. |
A parallel_dist.
Computes sum_j E[T_j] exactly when every component implements a
mean() method. Falls back to a Monte Carlo estimate from the
sampler when any component lacks an exact mean (e.g., a
dist_structure component whose mean would route through
algebraic.dist::univariate_dist and require density / sup,
which are not provided on dist_structure by default).
## S3 method for class 'cold_standby_dist' mean(x, ...)## S3 method for class 'cold_standby_dist' mean(x, ...)
x |
A |
... |
Passed to the Monte Carlo fallback as |
Numeric scalar.
Minimal cut sets
## S3 method for class 'dist_structure' min_cuts(x) min_cuts(x)## S3 method for class 'dist_structure' min_cuts(x) min_cuts(x)
x |
A dist_structure object. |
A list of integer vectors.
Equivalent to the minimum of m iid random variables from d. Unlike
min in the base distribution algebra, min_iid preserves the series
topology so structural queries (phi, min_paths, structural_importance)
remain available.
min_iid(d, m)min_iid(d, m)
d |
A |
m |
Number of components (positive integer). |
A series_dist.
sys <- min_iid(algebraic.dist::exponential(1), m = 3) # System survival at t=0.5 equals (exp(-t))^3 = exp(-1.5)sys <- min_iid(algebraic.dist::exponential(1), m = 3) # System survival at t=0.5 equals (exp(-t))^3 = exp(-1.5)
Returns the minimal subsets of 1:m whose joint functioning is
sufficient for the system to function. min_paths and phi() are
dual primitives in the dist_structure protocol: providing one is
enough, the other has an enumerative default.
## S3 method for class 'dist_structure' min_paths(x) min_paths(x)## S3 method for class 'dist_structure' min_paths(x) min_paths(x)
x |
A dist_structure object. |
A list of integer vectors.
phi() for the dual primitive; min_cuts() for the dual
topology query (minimal subsets whose joint failure causes system
failure).
Number of components
ncomponents(x)ncomponents(x)
x |
A dist_structure object. |
A positive integer m, the number of components.
Constructs a kofn_dist whose system lifetime equals T_(k), the
k-th order statistic of m iid draws from d. Under the k-of-m
parametrization, the system fails at the (m - k + 1)-th component
failure; setting the threshold to m - k + 1 makes the system lifetime
equal T_(k).
order_statistic(d, k, m)order_statistic(d, k, m)
d |
A |
k |
The order statistic index (1 = min, m = max). |
m |
Number of iid components. |
The internal call is kofn_dist(m - k + 1, ...): this maps the
order-statistic index k (where k = 1 is the minimum, k = m is
the maximum) to the :G convention used by kofn_dist (where the
k_dist argument is the number of functioning components required).
A kofn_dist.
# Median of 5 iid exponentials sys <- order_statistic(algebraic.dist::exponential(1), k = 3, m = 5)# Median of 5 iid exponentials sys <- order_statistic(algebraic.dist::exponential(1), k = 3, m = 5)
A parallel system fails only when all components fail. Equivalent to
max(components) but preserves topology.
parallel_dist(components)parallel_dist(components)
components |
List of |
A parallel_dist inheriting from coherent_dist.
Evaluate the coherent structure function phi: {0, 1}^m -> {0, 1} at a
component state vector state. By convention state[j] = 1 means
component j is functioning; phi(state) = 1 means the system is
functioning.
## S3 method for class 'dist_structure' phi(x, state) phi(x, state)## S3 method for class 'dist_structure' phi(x, state) phi(x, state)
x |
A dist_structure object. |
state |
Integer or logical vector of length |
phi and min_paths() are dual primitives: if a subclass provides
only phi.<class>(), the default min_paths.dist_structure()
enumerates minimal subsets via phi; if a subclass provides only
min_paths.<class>(), the default phi.dist_structure() checks
whether state covers any minimal path. Subclasses providing both
must keep them consistent.
Integer scalar, 0 or 1.
min_paths() for the dual primitive; validate_dist_structure()
for construction-time checking.
Print a dist_structure object
## S3 method for class 'dist_structure' print(x, ...)## S3 method for class 'dist_structure' print(x, ...)
x |
A dist_structure object. |
... |
Passed to |
x, invisibly.
R(p) = E[phi(X)] where X_j ~ Bernoulli(p_j) independent. The
multilinear extension of phi to component reliabilities.
## S3 method for class 'dist_structure' reliability(x, p) reliability(x, p)## S3 method for class 'dist_structure' reliability(x, p) reliability(x, p)
x |
A dist_structure object. |
p |
Numeric vector of length |
Numeric scalar in [0, 1].
A series system fails if any single component fails. Equivalent to
min(components) as random variables; unlike min in the base algebra,
series_dist preserves the component decomposition so topology queries
work.
series_dist(components)series_dist(components)
components |
List of |
A series_dist inheriting from coherent_dist.
sys <- series_dist(replicate(3, algebraic.dist::exponential(1), simplify = FALSE)) algebraic.dist::surv(sys)(0.5)sys <- series_dist(replicate(3, algebraic.dist::exponential(1), simplify = FALSE)) algebraic.dist::surv(sys)(0.5)
Fraction of the 2^(m - 1) states of the other components for which
component j is critical.
## S3 method for class 'dist_structure' structural_importance(x, j) structural_importance(x, j)## S3 method for class 'dist_structure' structural_importance(x, j) structural_importance(x, j)
x |
A dist_structure object. |
j |
Component index. |
Numeric scalar in [0, 1].
Return a new dist_structure with the j-th component replaced by
new_component. Topology is preserved; the returned object is a
coherent_dist with the same min_paths and the modified component
list.
## S3 method for class 'dist_structure' substitute_component(x, j, new_component) substitute_component(x, j, new_component)## S3 method for class 'dist_structure' substitute_component(x, j, new_component) substitute_component(x, j, new_component)
x |
A dist_structure object. |
j |
Component index. |
new_component |
A dist-compatible object to install at position j. |
A new dist_structure object.
Returns a closure function(t, ...) where surv(x)(t) equals
reliability(x, surv(component(x, j))(t) for each j). This is the
classical identity S_sys(t) = R(S(t)) realized as a composition.
Returns a closure function(n, ...) that draws n system lifetimes by
sampling each component independently and applying system_lifetime()
to combine.
dist_structure is the virtual S3 class for distributions whose random
variable has internal component structure: coherent reliability
systems decomposed into components arranged by a structure function.
Every concrete implementation (coherent_dist, series_dist,
parallel_dist, kofn_dist, bridge_dist, or user-defined
subclasses) should include "dist_structure", the algebraic.dist
ancestor "univariate_dist", and "dist" in its class vector.
## S3 method for class 'dist_structure' surv(x, ...) ## S3 method for class 'dist_structure' cdf(x, ...) ## S3 method for class 'dist_structure' sampler(x, ...)## S3 method for class 'dist_structure' surv(x, ...) ## S3 method for class 'dist_structure' cdf(x, ...) ## S3 method for class 'dist_structure' sampler(x, ...)
x |
A dist_structure object. |
... |
Ignored. |
Concrete implementations provide S3 methods for the generics in this
package. The minimum required methods are ncomponents(), component(),
and one of phi() or min_paths(); every other generic has a default
method on dist_structure that composes the primitives.
If both phi.<class>() and min_paths.<class>() are provided, the
implementor is responsible for keeping them consistent: phi derives
the in-package generics reliability, critical_states, and
is_coherent; min_paths derives min_cuts and system_signature.
Inconsistent implementations produce silently inconsistent results.
This help topic documents the virtual base class together with the three distribution-algebra default methods that compose component distributions through the topology:
surv.dist_structure() returns a closure function(t, ...) that
evaluates the system survival function via the reliability identity
S_sys(t) = R(S_1(t), ..., S_m(t)).
cdf.dist_structure() returns a closure function(t, ...) equal
to 1 - surv(x)(t).
sampler.dist_structure() returns a closure function(n, ...)
that draws n independent system lifetimes by sampling each
component and combining via system_lifetime().
Concrete subclasses override any of these for closed-form speed; see the closed-form specializations under the See Also entries.
validate_dist_structure() for an implementor-side
construction-time validator. phi() and min_paths() for the
bidirectional protocol primitives. The closed-form families
(exp_series(), wei_kofn(), etc.) for reference implementations.
Per-component censoring from system observation
## S3 method for class 'dist_structure' system_censoring(x, times) system_censoring(x, times)## S3 method for class 'dist_structure' system_censoring(x, times) system_censoring(x, times)
x |
A dist_structure object. |
times |
Non-negative numeric vector of length |
A list with system_time (scalar) and component_status
(character vector of length m, values in "exact", "left",
"right").
System lifetime from component times
## S3 method for class 'dist_structure' system_lifetime(x, times) system_lifetime(x, times)## S3 method for class 'dist_structure' system_lifetime(x, times) system_lifetime(x, times)
x |
A dist_structure object. |
times |
Non-negative numeric vector of length |
Scalar system lifetime.
Samaniego's signature: s = (s_1, ..., s_m) where s_k is the
probability the system fails at the k-th component failure under
i.i.d. absolutely-continuous component lifetimes. Only depends on the
structure (phi), not on the component distribution. A default method
on dist_structure enumerates the m! orderings; this is feasible
for m up to about 8 or 9. Specialized subclasses should override
with closed-form expressions.
## S3 method for class 'dist_structure' system_signature(x) system_signature(x)## S3 method for class 'dist_structure' system_signature(x) system_signature(x)
x |
A dist_structure object. |
Numeric vector of length ncomponents(x) summing to 1.
Checks that x declares "dist_structure" in its class chain and
provides the three required generics: ncomponents(), component(),
and at least one of phi() or min_paths().
validate_dist_structure(x)validate_dist_structure(x)
x |
An object claiming to satisfy the |
Useful in subclass constructors to fail fast with a clear error message rather than at first method dispatch (where the user sees opaque "no applicable method" errors). A typical pattern:
my_subclass <- function(...) {
obj <- structure(list(...), class = c("my_subclass", "dist_structure",
"univariate_dist", "continuous_dist", "dist"))
validate_dist_structure(obj)
obj
}
TRUE (invisibly) if all checks pass. Stops with an
informative error otherwise.
# Success: a valid dist_structure (any built-in topology shortcut works). validate_dist_structure(series_dist(replicate(3, algebraic.dist::exponential(1), simplify = FALSE))) # Failure: an object that declares dist_structure but provides no # primitives. Wrapped in tryCatch for the example's success status. bad <- structure(list(), class = c("not_a_real_class", "dist_structure", "univariate_dist", "continuous_dist", "dist")) tryCatch(validate_dist_structure(bad), error = function(e) conditionMessage(e))# Success: a valid dist_structure (any built-in topology shortcut works). validate_dist_structure(series_dist(replicate(3, algebraic.dist::exponential(1), simplify = FALSE))) # Failure: an object that declares dist_structure but provides no # primitives. Wrapped in tryCatch for the example's success status. bad <- structure(list(), class = c("not_a_real_class", "dist_structure", "univariate_dist", "continuous_dist", "dist")) tryCatch(validate_dist_structure(bad), error = function(e) conditionMessage(e))
Probability that at least one minimal cut set containing j has all
its components failed, given the system has failed by time t.
Computed exactly via inclusion-exclusion over subsets of cuts that
contain j.
vesely_fussell_importance(x, j, t) ## S3 method for class 'dist_structure' vesely_fussell_importance(x, j, t)vesely_fussell_importance(x, j, t) ## S3 method for class 'dist_structure' vesely_fussell_importance(x, j, t)
x |
A dist_structure object. |
j |
Component index. |
t |
Scalar time. |
Numeric scalar in [0, 1].
Constructs a dist_structure for a series of Weibull components sharing
a common shape parameter. By the standard identity, the system lifetime
is itself Weibull with the common shape and an aggregate scale
(sum(1 / scale^shape))^(-1 / shape). Methods for surv, cdf,
sampler, and mean forward to this aggregate Weibull, giving exact
closed-form values.
wei_homogeneous_series(shape, scales) ## S3 method for class 'wei_homogeneous_series' surv(x, ...) ## S3 method for class 'wei_homogeneous_series' sampler(x, ...) ## S3 method for class 'wei_homogeneous_series' mean(x, ...)wei_homogeneous_series(shape, scales) ## S3 method for class 'wei_homogeneous_series' surv(x, ...) ## S3 method for class 'wei_homogeneous_series' sampler(x, ...) ## S3 method for class 'wei_homogeneous_series' mean(x, ...)
shape |
Positive scalar: common Weibull shape. |
scales |
Positive numeric vector: per-component Weibull scales. |
x |
A |
... |
Ignored. |
wei_homogeneous_series() returns an object of class
c("wei_homogeneous_series", "wei_series", "series_dist", "coherent_dist", "dist_structure", "univariate_dist", "continuous_dist", "dist").
The associated S3 methods return:
surv(): a closure function(t, ...).
cdf() is derived via the dist_structure default and returns
a closure function(t, ...) equal to 1 - surv(x)(t).
sampler(): a closure function(n, ...) returning n random
variates from the system lifetime distribution.
mean(): a numeric scalar (the mean system lifetime,
aggregate_scale * gamma(1 + 1 / shape)).
sys <- wei_homogeneous_series(shape = 2, scales = c(1, 2, 3)) # System lifetime is Weibull(shape = 2, scale = aggregate_scale) algebraic.dist::surv(sys)(1)sys <- wei_homogeneous_series(shape = 2, scales = c(1, 2, 3)) # System lifetime is Weibull(shape = 2, scale = aggregate_scale) algebraic.dist::surv(sys)(1)
Constructs a dist_structure for a k-out-of-m system whose components
are independent (possibly heterogeneous) Weibulls. Closed-form surv,
cdf, sampler, density, and hazard via subset enumeration,
the critical-state density formula, and component order statistics.
wei_kofn(k, shapes, scales) ## S3 method for class 'wei_kofn' surv(x, ...) ## S3 method for class 'wei_kofn' sampler(x, ...) ## S3 method for class 'wei_kofn' hazard(x, ...) ## S3 method for class 'wei_kofn' density(x, ...)wei_kofn(k, shapes, scales) ## S3 method for class 'wei_kofn' surv(x, ...) ## S3 method for class 'wei_kofn' sampler(x, ...) ## S3 method for class 'wei_kofn' hazard(x, ...) ## S3 method for class 'wei_kofn' density(x, ...)
k |
Minimum functioning components for system operation. |
shapes |
Positive numeric vector of length |
scales |
Positive numeric vector of length |
x |
A |
... |
Ignored. |
wei_kofn() returns an object of class
c("wei_kofn", "kofn_dist", "coherent_dist", "dist_structure", "univariate_dist", "continuous_dist", "dist").
The associated S3 methods return:
surv(), density(), hazard(): a closure function(t, ...).
cdf() is derived via the dist_structure default and returns
a closure function(t, ...) equal to 1 - surv(x)(t).
sampler(): a closure function(n, ...) returning n random
variates from the system lifetime distribution.
sys <- wei_kofn(k = 2, shapes = c(1, 2, 3), scales = c(1, 2, 3)) algebraic.dist::surv(sys)(1)sys <- wei_kofn(k = 2, shapes = c(1, 2, 3), scales = c(1, 2, 3)) algebraic.dist::surv(sys)(1)
Constructs a dist_structure representing a series system whose
components are independent Weibull distributions with possibly
different shapes and scales. Closed-form methods are provided for
surv, cdf, sampler, and algebraic.dist::hazard.
wei_series(shapes, scales) ## S3 method for class 'wei_series' surv(x, ...) ## S3 method for class 'wei_series' sampler(x, ...) ## S3 method for class 'wei_series' hazard(x, ...)wei_series(shapes, scales) ## S3 method for class 'wei_series' surv(x, ...) ## S3 method for class 'wei_series' sampler(x, ...) ## S3 method for class 'wei_series' hazard(x, ...)
shapes |
Positive numeric vector of length |
scales |
Positive numeric vector of length |
x |
A |
... |
Ignored. |
wei_series() returns an object of class
c("wei_series", "series_dist", "coherent_dist", "dist_structure", "univariate_dist", "continuous_dist", "dist").
The associated S3 methods return:
surv(), hazard(): a closure function(t, ...).
cdf() is derived via the dist_structure default and returns
a closure function(t, ...) equal to 1 - surv(x)(t).
sampler(): a closure function(n, ...) returning n random
variates from the system lifetime distribution.
sys <- wei_series(shapes = c(1, 2, 3), scales = c(1, 2, 3)) algebraic.dist::surv(sys)(1)sys <- wei_series(shapes = c(1, 2, 3), scales = c(1, 2, 3)) algebraic.dist::surv(sys)(1)