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: SequenceEncodableProbabilityDistribution

Inhomogeneous 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/marks are accepted for TemporalPointProcess signature parity and ignored. Raises ValueError for t outside the support [edges[0], edges[-1]].

Parameters:
Return type:

float

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/marks are accepted for signature parity and ignored. With t_start=edges[0], t_end=edges[-1] this returns the full integral sum_b rate_b width_b used by log_density.

Parameters:
Return type:

float

density(x)[source]

Probability density of one realization x (a sequence of event times).

Parameters:

x (Any)

Return type:

float

log_density(x)[source]

Log-likelihood of one realization: sum_b n_b log rate_b - sum_b rate_b width_b.

Parameters:

x (Any)

Return type:

float

seq_log_density(x)[source]

Vectorized log-likelihood for a (num_realizations, num_bins) matrix of per-bin counts.

Parameters:

x (ndarray)

Return type:

ndarray

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: DistributionSampler

Draw realizations by binwise thinning: n_b ~ Poisson(rate_b * width_b) then uniform times.

Parameters:
  • dist (InhomogeneousPoissonProcessDistribution)

  • seed (int | None)

sample(size=None)[source]

Draw one realization (event-time array) or a list of size realizations.

Parameters:

size (int | None)

Return type:

ndarray | list[ndarray]

class InhomogeneousPoissonProcessAccumulator(edges, name=None, keys=None)[source]

Bases: SequenceEncodableStatisticAccumulator

Accumulate weighted per-bin event counts and the weighted number of realizations.

Parameters:
update(x, weight, estimate)[source]
Parameters:
  • x (Any)

  • weight (float)

  • estimate (InhomogeneousPoissonProcessDistribution | None)

Return type:

None

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

None

seq_update(x, weights, estimate)[source]
Parameters:
Return type:

None

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

None

combine(suff_stat)[source]
Parameters:

suff_stat (tuple[ndarray, float])

Return type:

InhomogeneousPoissonProcessAccumulator

value()[source]
Return type:

tuple[ndarray, float]

from_value(x)[source]
Parameters:

x (tuple[ndarray, float])

Return type:

InhomogeneousPoissonProcessAccumulator

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_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:

InhomogeneousPoissonProcessDataEncoder

class InhomogeneousPoissonProcessAccumulatorFactory(edges, name=None, keys=None)[source]

Bases: StatisticAccumulatorFactory

Factory for InhomogeneousPoissonProcessAccumulator.

Parameters:
make()[source]
Return type:

InhomogeneousPoissonProcessAccumulator

class InhomogeneousPoissonProcessEstimator(num_bins=None, t_max=None, edges=None, name=None, keys=None)[source]

Bases: ParameterEstimator

Closed-form MLE: rate_b = (weighted events in bin b) / (width_b * weighted realizations).

Parameters:
accumulator_factory()[source]
Return type:

InhomogeneousPoissonProcessAccumulatorFactory

estimate(nobs, suff_stat)[source]

Estimate per-bin rates from accumulated (bin_counts, n_realizations).

Parameters:
Return type:

InhomogeneousPoissonProcessDistribution

class InhomogeneousPoissonProcessDataEncoder(edges)[source]

Bases: DataSequenceEncoder

Encode a list of realizations (event-time arrays) into a (num_realizations, num_bins) count matrix.

Parameters:

edges (Sequence[float] | ndarray)

seq_encode(x)[source]

Encode the iid observation sequence x for vectorized evaluation.

Parameters:

x (Sequence[Any])

Return type:

ndarray