mixle.stats.combinator.survival module¶
Survival model with right-censoring: a bundled event-time + censoring-indicator likelihood.
Survival/reliability data is (t, event): either the event was observed at time t (event=1)
or the unit was still alive when observation stopped, a right-censored time (event=0, the true
event is only known to be > t). The likelihood bundles the density for observed events with the
survival function for censored ones:
log L = sum_{event} log f(t) + sum_{censored} log S(t), S(t) = 1 - F(t).
SurvivalDistribution wraps any event-time base that exposes cdf and quantile (Weibull,
Exponential, GeneralizedPareto, GeneralizedExtremeValue, …). Censoring is exogenous, so the only
parameters are the base’s; fitting them under censoring is the standard EM that imputes the unobserved
event times: a censored time c contributes the base’s mass beyond c, approximated
deterministically by a grid of conditional quantiles F^{-1}(F(c) + q (1 - F(c))). Each mixle EM
iteration re-imputes with the improved base, converging to the right-censored MLE – which, unlike
fitting on the observed events alone, is unbiased.
- class SurvivalDistribution(base, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionRight-censored survival likelihood over a base event-time distribution.
- density(x)[source]
Return the likelihood contribution of
(t, event).
- log_density(x)[source]
Return
log f(t)for an observed event, elselog S(t)for a right-censored time.
- seq_log_density(x)[source]
Vectorized likelihood: base density for events, log survival for censored rows.
- sampler(seed=None)[source]
Return a sampler (draws uncensored event times; censoring is exogenous).
- Parameters:
seed (int | None)
- Return type:
SurvivalSampler
- estimator(pseudo_count=None)[source]
Return an estimator that fits the base under right-censoring by conditional-quantile EM.
- Parameters:
pseudo_count (float | None)
- Return type:
SurvivalEstimator
- dist_to_encoder()[source]
Return the data encoder (base encoding of the times + the event mask).
- Return type:
SurvivalDataEncoder
- class SurvivalSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw uncensored event times
(t, 1)from the base (censoring is applied externally).- Parameters:
dist (SurvivalDistribution)
seed (int | None)
- class SurvivalAccumulator(base_accumulator, base_encoder, n_impute=16, keys=None)[source]
Bases:
SingleChildAccumulatorFeed observed events and conditional-quantile imputations of censored times to the base accumulator.
- Parameters:
- update(x, weight, estimate)[source]
Accumulate one observed or right-censored event-time record.
- initialize(x, weight, rng)[source]
Initialize the base sufficient statistics from one survival record.
- Parameters:
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Accumulate encoded survival records using conditional-tail imputation.
- Parameters:
weights (ndarray)
estimate (SurvivalDistribution)
- Return type:
None
- seq_initialize(x, weights, rng)[source]
Initialize from encoded survival records without a current estimate.
- Parameters:
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- scale(c)[source]
Scale the delegated base sufficient statistics by a constant.
- Parameters:
c (float)
- Return type:
SurvivalAccumulator
- acc_to_encoder()[source]
Return an encoder that records event times and censoring indicators.
- Return type:
SurvivalDataEncoder
- class SurvivalAccumulatorFactory(base_factory, base_encoder, n_impute, keys)[source]
Bases:
StatisticAccumulatorFactoryFactory for
SurvivalAccumulator.- Parameters:
- make()[source]
Create an empty survival accumulator.
- Return type:
SurvivalAccumulator
- class SurvivalEstimator(base_estimator, n_impute=16, name=None, keys=None)[source]
Bases:
ParameterEstimatorFit the base event-time distribution under right-censoring (conditional-quantile imputation EM).
- accumulator_factory()[source]
Return a factory for right-censored survival sufficient-statistic accumulators.
- Return type:
SurvivalAccumulatorFactory
- class SurvivalDataEncoder(base_encoder)[source]
Bases:
MaskedBaseEncoderEncode
(t, event)data as the base encoding of the times plus the boolean event mask.- Parameters:
base_encoder (DataSequenceEncoder)