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 fits the inter-arrival distribution to the observed gaps via that distribution’s own estimator – the standard renewal-process MLE. The censored-boundary term contributes to the likelihood (scoring) but not to the M-step; its effect on the fitted parameters is O(1/n_events) and vanishes as the window spans many inter-arrivals, so the estimator is consistent. (A fully boundary-corrected M-step would require a censored-data estimator for the inter-arrival family; that is a deliberate, documented follow-up.) The window T is a fixed, known observation parameter, not estimated.

class RenewalProcessDistribution(interarrival, window, name=None, keys=None)[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)

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)[source]

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

Parameters:

size (int | None)

Return type:

ndarray | list[ndarray]

class RenewalProcessAccumulator(gap_accumulator, 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)

  • 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, name=None, keys=None)[source]

Bases: StatisticAccumulatorFactory

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

Parameters:
  • gap_factory (StatisticAccumulatorFactory)

  • 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)[source]

Bases: ParameterEstimator

Fit the inter-arrival distribution to observed gaps (standard renewal-process MLE).

Parameters:
  • interarrival_estimator (ParameterEstimator)

  • window (float)

  • name (str | None)

  • keys (str | None)

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 into (flattened-gap child encoding, segment ids, count, remaining, validity).

Parameters:
  • gap_encoder (DataSequenceEncoder)

  • window (float | None)

seq_encode(x)[source]

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

Parameters:

x (Sequence[Any])

Return type:

Any