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]
Accumulate weighted per-bin counts for one event-time realization.
- initialize(x, weight, rng)[source]
Initialize the sufficient statistics with one weighted realization.
- Parameters:
x (Any)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Accumulate weighted per-bin counts from encoded realizations.
- seq_initialize(x, weights, rng)[source]
Initialize the sufficient statistics from encoded realizations.
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
Merge serialized bin-count statistics into this accumulator.
- value()[source]
Return the weighted bin counts and weighted realization count.
- from_value(x)[source]
Restore the accumulator from serialized bin-count statistics.
- scale(c)[source]
Scale accumulated sufficient statistics by a constant.
- Parameters:
c (float)
- Return type:
InhomogeneousPoissonProcessAccumulator
- key_merge(stats_dict)[source]
Merge this accumulator into a keyed statistics dictionary.
- key_replace(stats_dict)[source]
Replace this accumulator from a keyed statistics dictionary.
- acc_to_encoder()[source]
Return an encoder that bins event times on this accumulator’s edges.
- Return type:
InhomogeneousPoissonProcessDataEncoder
- class InhomogeneousPoissonProcessAccumulatorFactory(edges, name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for InhomogeneousPoissonProcessAccumulator.
- make()[source]
Create an empty inhomogeneous Poisson process accumulator.
- 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 a factory for inhomogeneous Poisson sufficient-statistic accumulators.
- Return type:
InhomogeneousPoissonProcessAccumulatorFactory
- class InhomogeneousPoissonProcessDataEncoder(edges)[source]
Bases:
DataSequenceEncoderEncode a list of realizations (event-time arrays) into a
(num_realizations, num_bins)count matrix.