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 observations.

Combinator samplers (mixture/sequence/…) accept batched. With batched=True (the default) each child stream is drawn in one vectorized call instead of a per-draw Python loop – far faster. Because every child sampler owns an independent RandomState, batching consumes each stream in the same order as the loop, so the draws are identical to the legacy path. batched=False forces that legacy per-draw loop as a guaranteed- stable reference. Leaf samplers are already vectorized and ignore the flag.

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]
Parameters:
  • x (Any)

  • weight (float)

  • estimate (RenewalProcessDistribution | None)

Return type:

None

initialize(x, weight, rng)[source]
Parameters:
Return type:

None

seq_update(x, weights, estimate)[source]
Parameters:
  • x (Any)

  • weights (ndarray)

  • estimate (RenewalProcessDistribution | None)

Return type:

None

seq_initialize(x, weights, rng)[source]
Parameters:
Return type:

None

combine(suff_stat)[source]
Parameters:

suff_stat (Any)

Return type:

RenewalProcessAccumulator

value()[source]
Return type:

Any

from_value(x)[source]
Parameters:

x (Any)

Return type:

RenewalProcessAccumulator

scale(c)[source]

Scale linear sufficient statistics in-place by c.

The structural default is correct for ordinary weighted sums, nested tuples/lists/dicts, and numeric arrays. Families whose value() payload includes non-linear metadata such as support bounds must override this method and leave that metadata unscaled.

Parameters:

c (float)

Return type:

RenewalProcessAccumulator

key_merge(stats_dict)[source]

Pool this accumulator’s statistics into stats_dict under its merge key.

The structural default implements the common single-key pattern: store the accumulator under self.keys the first time the key is seen, else combine into the one already there. Accumulators with several named keys (e.g. an HMM’s init/trans/state keys) or a non-accumulator stats payload override this. A keys of None (the default) is a no-op.

Parameters:

stats_dict (dict[str, Any])

Return type:

None

key_replace(stats_dict)[source]

Replace this accumulator’s statistics from the pooled stats_dict entry (see key_merge).

Parameters:

stats_dict (dict[str, Any])

Return type:

None

acc_to_encoder()[source]
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]
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 type:

RenewalProcessAccumulatorFactory

estimate(nobs, suff_stat)[source]
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 the iid observation sequence x for vectorized evaluation.

Parameters:

x (Sequence[Any])

Return type:

Any