mixle.stats.processes.inhomogeneous_poisson module¶
Evaluate, estimate, and sample from an inhomogeneous Poisson process with piecewise-constant rate.
Defines InhomogeneousPoissonProcessDistribution, InhomogeneousPoissonProcessSampler, InhomogeneousPoissonProcessAccumulatorFactory, InhomogeneousPoissonProcessAccumulator, InhomogeneousPoissonProcessEstimator, and InhomogeneousPoissonProcessDataEncoder.
Data type: each observation is a 1-D array/list of event times within the window
[edges[0], edges[-1]]. The intensity lambda(t) is constant rates[b] on bin b (the
bins are given by edges; uniform bins on [0, t_max] by default). The log-likelihood of one
realization with per-bin event counts n_b is
sum_b n_b * log(rates[b]) - sum_b rates[b] * width[b],
i.e. the standard Poisson-process log-likelihood sum_i log lambda(t_i) - integral lambda. The
MLE is closed-form: rates[b] = (total events in bin b) / (width[b] * n_realizations).
Reference: Daley & Vere-Jones, An Introduction to the Theory of Point Processes (Springer, 2003).
- class InhomogeneousPoissonProcessDistribution(rates, t_max=None, edges=None, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionInhomogeneous Poisson process with piecewise-constant intensity on a fixed window.
- Parameters:
- intensity(t, times=None, marks=None)[source]
Conditional rate
lambda(t) = rates[bin containing t].The inhomogeneous Poisson process is not self-exciting, so the rate depends only on
t.times/marksare accepted forTemporalPointProcesssignature parity and ignored. RaisesValueErrorfortoutside the support[edges[0], edges[-1]].
- expected_count(t_start, t_end, times=None, marks=None)[source]
Compensator
integral_{t_start}^{t_end} lambda(s) ds– the piecewise-rate integral.Computed as
sum_b rate_b * width(overlap([t_start, t_end], bin_b)).times/marksare accepted for signature parity and ignored. Witht_start=edges[0], t_end=edges[-1]this returns the full integralsum_b rate_b width_bused bylog_density.
- density(x)[source]
Probability density of one realization
x(a sequence of event times).
- log_density(x)[source]
Log-likelihood of one realization:
sum_b n_b log rate_b - sum_b rate_b width_b.
- seq_log_density(x)[source]
Vectorized log-likelihood for a
(num_realizations, num_bins)matrix of per-bin counts.
- sampler(seed=None)[source]
Return an InhomogeneousPoissonProcessSampler for this distribution.
- Parameters:
seed (int | None)
- Return type:
InhomogeneousPoissonProcessSampler
- estimator(pseudo_count=None)[source]
Return an InhomogeneousPoissonProcessEstimator over the same bin edges.
- Parameters:
pseudo_count (float | None)
- Return type:
InhomogeneousPoissonProcessEstimator
- dist_to_encoder()[source]
Returns an InhomogeneousPoissonProcessDataEncoder bound to these bin edges.
- Return type:
InhomogeneousPoissonProcessDataEncoder
- class InhomogeneousPoissonProcessSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw realizations by binwise thinning:
n_b ~ Poisson(rate_b * width_b)then uniform times.- Parameters:
dist (InhomogeneousPoissonProcessDistribution)
seed (int | None)
- class InhomogeneousPoissonProcessAccumulator(edges, name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate weighted per-bin event counts and the weighted number of realizations.
- 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 (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
- from_value(x)[source]
- 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:
InhomogeneousPoissonProcessAccumulator
- 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:
InhomogeneousPoissonProcessDataEncoder
- class InhomogeneousPoissonProcessAccumulatorFactory(edges, name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for InhomogeneousPoissonProcessAccumulator.
- make()[source]
- Return type:
InhomogeneousPoissonProcessAccumulator
- class InhomogeneousPoissonProcessEstimator(num_bins=None, t_max=None, edges=None, name=None, keys=None)[source]
Bases:
ParameterEstimatorClosed-form MLE:
rate_b = (weighted events in bin b) / (width_b * weighted realizations).- Parameters:
- accumulator_factory()[source]
- Return type:
InhomogeneousPoissonProcessAccumulatorFactory
- class InhomogeneousPoissonProcessDataEncoder(edges)[source]
Bases:
DataSequenceEncoderEncode a list of realizations (event-time arrays) into a
(num_realizations, num_bins)count matrix.