mixle.stats.processes.renewal_process module

Renewal process – a point process whose inter-arrival times are i.i.d. from a base distribution.

A renewal process on the window [0, T] generates event times 0 < t_1 < t_2 < ... < t_n <= T such that the gaps g_1 = t_1, g_i = t_i - t_{i-1} are i.i.d. draws from a positive-support inter-arrival distribution f (e.g. Gamma, Weibull, LogGaussian, InverseGaussian, Exponential – the Poisson process is the Exponential special case). The exact log-likelihood of one realization is

log L = sum_i log f(g_i) + log S(T - t_n), S(x) = 1 - F(x) (the survival of the censored last gap)

where the final term is the probability that no further event occurred before the window closed (with t_0 = 0 and t_n = 0 when there are no events, so an empty realization scores log S(T)). Scoring is therefore exact, including the right-censored boundary.

Estimation retains both completed gaps and every realization’s right-censored tail, and fits the full finite-window likelihood. Exponential inter-arrivals use an exact closed-form censored MLE/update; Gamma, Weibull, LogGaussian, and InverseGaussian inter-arrivals use bounded numerical likelihood optimization. Other child estimators fail closed instead of silently discarding censoring. The window T is fixed, known configuration and is never estimated.

class RenewalProcessStatistics(gap_statistics, completed_gaps, completed_weights, censored_times, censored_weights)[source]

Bases: NamedTuple

Versioned renewal evidence including right-censoring.

Parameters:
gap_statistics: Any

Alias for field number 0

completed_gaps: ndarray

Alias for field number 1

completed_weights: ndarray

Alias for field number 2

censored_times: ndarray

Alias for field number 3

censored_weights: ndarray

Alias for field number 4

property schema_version: int

Return the serialized statistic schema version.

class RenewalProcessDistribution(interarrival, window, name=None, keys=None, max_events=_DEFAULT_MAX_EVENTS)[source]

Bases: SequenceEncodableProbabilityDistribution

Renewal process with i.i.d. inter-arrivals interarrival observed on [0, window].

Parameters:
  • interarrival (Any)

  • window (float)

  • name (str | None)

  • keys (str | None)

  • max_events (int)

log_density(x)[source]

Exact log-likelihood of one realization (observed gaps + censored survival).

Parameters:

x (Any)

Return type:

float

seq_log_density(x)[source]

Vectorized log-likelihood for encoded realizations (flattened gaps + per-realization survival).

Parameters:

x (Any)

Return type:

ndarray

sampler(seed=None)[source]

Return a sampler that draws gaps until the cumulative time exceeds window.

Parameters:

seed (int | None)

Return type:

RenewalProcessSampler

estimator(pseudo_count=None)[source]

Return an estimator that fits the inter-arrival distribution to the observed gaps.

Parameters:

pseudo_count (float | None)

Return type:

RenewalProcessEstimator

dist_to_encoder()[source]

Return the data encoder (delegates gap encoding to the inter-arrival encoder).

Return type:

RenewalProcessDataEncoder

class RenewalProcessSampler(dist, seed=None)[source]

Bases: DistributionSampler

Draw inter-arrival gaps from interarrival until the cumulative time passes window.

Parameters:
  • dist (RenewalProcessDistribution)

  • seed (int | None)

sample(size=None, *, batched=True)[source]

Draw one realization, or size iid realizations, on the fixed window.

Parameters:
Return type:

ndarray | list[ndarray]

class RenewalProcessAccumulator(gap_accumulator, window, name=None, keys=None)[source]

Bases: SequenceEncodableStatisticAccumulator

Feed the inter-arrival gaps to the inter-arrival distribution’s accumulator (renewal MLE).

Parameters:
  • gap_accumulator (SequenceEncodableStatisticAccumulator)

  • window (float)

  • name (str | None)

  • keys (str | None)

update(x, weight, estimate)[source]

Accumulate observed inter-arrival gaps from one realization.

Parameters:
  • x (Any)

  • weight (float)

  • estimate (RenewalProcessDistribution | None)

Return type:

None

initialize(x, weight, rng)[source]

Initialize the gap accumulator from one realization.

Parameters:
Return type:

None

seq_update(x, weights, estimate)[source]

Accumulate encoded observed gaps with realization-level weights.

Parameters:
  • x (Any)

  • weights (ndarray)

  • estimate (RenewalProcessDistribution | None)

Return type:

None

seq_initialize(x, weights, rng)[source]

Initialize from encoded observed gaps.

Parameters:
Return type:

None

combine(suff_stat)[source]

Merge another inter-arrival sufficient-statistic value.

Parameters:

suff_stat (Any)

Return type:

RenewalProcessAccumulator

value()[source]

Return the wrapped inter-arrival accumulator value.

Return type:

Any

from_value(x)[source]

Replace the wrapped inter-arrival accumulator from x.

Parameters:

x (Any)

Return type:

RenewalProcessAccumulator

scale(c)[source]

Scale the wrapped inter-arrival sufficient statistics by c.

Parameters:

c (float)

Return type:

RenewalProcessAccumulator

key_merge(stats_dict)[source]

Delegate keyed statistic merging to the gap accumulator.

Parameters:

stats_dict (dict[str, Any])

Return type:

None

key_replace(stats_dict)[source]

Delegate keyed statistic replacement to the gap accumulator.

Parameters:

stats_dict (dict[str, Any])

Return type:

None

acc_to_encoder()[source]

Return an encoder that converts event times into inter-arrival gaps.

Return type:

RenewalProcessDataEncoder

class RenewalProcessAccumulatorFactory(gap_factory, window, name=None, keys=None)[source]

Bases: StatisticAccumulatorFactory

Factory for RenewalProcessAccumulator (wraps the inter-arrival accumulator factory).

Parameters:
  • gap_factory (StatisticAccumulatorFactory)

  • window (float)

  • name (str | None)

  • keys (str | None)

make()[source]

Create a fresh renewal-process accumulator.

Return type:

RenewalProcessAccumulator

class RenewalProcessEstimator(interarrival_estimator, window, name=None, keys=None, max_events=_DEFAULT_MAX_EVENTS)[source]

Bases: ParameterEstimator

Fit supported inter-arrival families to the full censored likelihood.

Parameters:
  • interarrival_estimator (ParameterEstimator)

  • window (float)

  • name (str | None)

  • keys (str | None)

  • max_events (int)

accumulator_factory()[source]

Return an accumulator factory for observed inter-arrival gaps.

Return type:

RenewalProcessAccumulatorFactory

estimate(nobs, suff_stat)[source]

Estimate the inter-arrival distribution and keep the fixed window.

Parameters:
Return type:

RenewalProcessDistribution

class RenewalProcessDataEncoder(gap_encoder, window)[source]

Bases: DataSequenceEncoder

Encode realizations with raw gaps, child encoding, and censoring metadata.

Parameters:
  • gap_encoder (DataSequenceEncoder)

  • window (float)

seq_encode(x)[source]

Encode event-time realizations into flattened gaps and censoring metadata.

Parameters:

x (Sequence[Any])

Return type:

Any

row_count(x)[source]

Return the validated number of encoded realizations.

Parameters:

x (Any)

Return type:

int