mixle.stats.processes.multivariate_hawkes module¶
Multivariate (mutually-exciting) Hawkes process with an exponential kernel.
A D-dimensional Hawkes process over marked events (t, mark) on a fixed window [0, T]. Each
mark has a baseline intensity mu_d and an event of mark j excites the intensity of mark d by
alpha_{dj} exp(-beta (t - t_k)), so
lambda_d(t) = mu_d + sum_{t_k < t} alpha_{d, mark_k} exp(-beta (t - t_k)),
coupling the dimensions through the D x D excitation matrix alpha (a shared decay beta). The
exact log-likelihood sum_n log lambda_{mark_n}(t_n) - sum_d \int_0^T lambda_d is computed in
O(n D) by a per-mark excitation recursion, sampling is by multivariate Ogata thinning, and the
parameters are fit by the Veen-Schoenberg branching EM (each event is an immigrant of its mark or the
offspring of an earlier event, with the excitation kernel as the parent likelihood). The process is
stationary when the spectral radius of alpha / beta is below 1.
Reference: Hawkes, ‘Spectra of some self-exciting and mutually exciting point processes’, Biometrika (1971).
- class MultivariateHawkesProcessDistribution(mu, alpha, beta, window, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionMultivariate Hawkes process: baselines
mu(D), excitationalpha(D, D), decaybeta.- Parameters:
- intensity(t, times, marks)[source]
Per-mark conditional rate vector (the vector-valued variant of
intensity).Returns
lambda(t)of shape(D,)withlambda_k(t) = mu_k + sum_{(t_i, m_i) < t} alpha[k, m_i] exp(-beta (t - t_i)).
- expected_count(t_start, t_end, times, marks)[source]
Per-mark compensator vector (the vector-valued variant of
expected_count).Returns
(D,)with the integral oflambda_kover[t_start, t_end]given the history.
- density(x)[source]
Probability density of one realization (a sequence of
(time, mark)events).
- log_density(x)[source]
Exact log-likelihood of one realization of marked events sorted by time.
- seq_log_density(x)[source]
Log-likelihood for a list of realizations.
- sampler(seed=None)[source]
Return a sampler (multivariate Ogata thinning).
- Parameters:
seed (int | None)
- Return type:
MultivariateHawkesProcessSampler
- estimator(pseudo_count=None)[source]
Return a branching-EM estimator over the same window and dimension.
- Parameters:
pseudo_count (float | None)
- Return type:
MultivariateHawkesProcessEstimator
- dist_to_encoder()[source]
Return the data encoder (passes realizations through; the likelihood is per-realization).
- Return type:
MultivariateHawkesProcessDataEncoder
- class MultivariateHawkesProcessSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw realizations by multivariate Ogata thinning.
- Parameters:
dist (MultivariateHawkesProcessDistribution)
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.- Parameters:
size (int | None)
- class MultivariateHawkesProcessAccumulator(dim, window, name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate the multivariate branching sufficient statistics.
- 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:
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
- Parameters:
suff_stat (tuple)
- Return type:
MultivariateHawkesProcessAccumulator
- 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:
MultivariateHawkesProcessAccumulator
- 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:
MultivariateHawkesProcessDataEncoder
- class MultivariateHawkesProcessAccumulatorFactory(dim, window, name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for MultivariateHawkesProcessAccumulator.
- make()[source]
- Return type:
MultivariateHawkesProcessAccumulator
- class MultivariateHawkesProcessEstimator(dim, window, name=None, keys=None)[source]
Bases:
ParameterEstimatorVeen-Schoenberg branching-EM estimator for the multivariate Hawkes parameters.
- accumulator_factory()[source]
- Return type:
MultivariateHawkesProcessAccumulatorFactory
- class MultivariateHawkesProcessDataEncoder(window, dim)[source]
Bases:
DataSequenceEncoderValidate and pass through realizations of marked events.