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:
SequenceEncodableProbabilityDistributionRenewal process with i.i.d. inter-arrivals
interarrivalobserved on[0, window].- log_density(x)[source]
Exact log-likelihood of one realization (observed gaps + censored survival).
- seq_log_density(x)[source]
Vectorized log-likelihood for encoded realizations (flattened gaps + per-realization survival).
- 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:
DistributionSamplerDraw inter-arrival gaps from
interarrivaluntil the cumulative time passeswindow.- Parameters:
dist (RenewalProcessDistribution)
seed (int | None)
- sample(size=None)[source]
Draw observations.
Combinator samplers (mixture/sequence/…) accept
batched. Withbatched=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 independentRandomState, batching consumes each stream in the same order as the loop, so the draws are identical to the legacy path.batched=Falseforces that legacy per-draw loop as a guaranteed- stable reference. Leaf samplers are already vectorized and ignore the flag.
- class RenewalProcessAccumulator(gap_accumulator, name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorFeed the inter-arrival gaps to the inter-arrival distribution’s accumulator (renewal MLE).
- Parameters:
- update(x, weight, estimate)[source]
- initialize(x, weight, rng)[source]
- Parameters:
x (Any)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
- seq_initialize(x, weights, rng)[source]
- Parameters:
x (Any)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- 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_dictunder its merge key.The structural default implements the common single-key pattern: store the accumulator under
self.keysthe first time the key is seen, elsecombineinto 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. AkeysofNone(the default) is a no-op.
- key_replace(stats_dict)[source]
Replace this accumulator’s statistics from the pooled
stats_dictentry (see key_merge).
- acc_to_encoder()[source]
- Return type:
RenewalProcessDataEncoder
- class RenewalProcessAccumulatorFactory(gap_factory, name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for RenewalProcessAccumulator (wraps the inter-arrival accumulator factory).
- make()[source]
- Return type:
RenewalProcessAccumulator
- class RenewalProcessEstimator(interarrival_estimator, window, name=None, keys=None)[source]
Bases:
ParameterEstimatorFit the inter-arrival distribution to observed gaps (standard renewal-process MLE).
- Parameters:
- accumulator_factory()[source]
- Return type:
RenewalProcessAccumulatorFactory