Simulation API#
Seedable numpy simulators and exact empty-history point-process likelihoods.
- class easy_tpp.simulation.HawkesProcess(mu, alpha, beta)#
Bases:
Processlambda_k(t) = mu_k + sum_{i:t_i<t} alpha[k,j_i] beta[k,j_i] exp(-beta[k,j_i] (t-t_i)). Columns are source types; rows are targets. alpha is the integrated kernel (branching matrix), NOT the jump height. Require nonnegative mu/alpha, positive beta and spectral radius(alpha)<1. Simulation starts empty, not in the stationary distribution.
- intensity(t, history)#
Left-limit intensity at scalar t; history is a (times, types) pair.
Events at t are excluded; history must not contain future events.
- loglik(times, types, t_end=None)#
Exact O(n K) likelihood, including survival through t_end.
Each source column stores its exponential sums at its most recent event. Query only the current target row, then update one column; this avoids a K x K update per event even for pair-specific beta.
- class easy_tpp.simulation.SelfCorrectingProcess(mu, alpha)#
Bases:
Processlambda_k(t) = exp(mu_k * t - alpha_k * N(t-)).
mu and alpha are nonnegative K-vectors; N counts all marks. Initial intensities are one. Zero mu is supported by the constant-rate limit.
- loglik(times, types, t_end=None)#
- easy_tpp.simulation.loglik_per_event(process, times, types, t_end=None)#
Total log likelihood divided by event count; undefined for empty input.
By default there is no survival term after the last event. This is a per-event average, not a loss (no sign flip). EasyTPP models may condition on the first event and report counts of scored events; align that convention separately before comparing. This helper scores every supplied event.
- easy_tpp.simulation.to_records(sequences, dim_process=None, t_end=None)#
Convert (times, types) pairs to EasyTPP records.
Without dim_process, infer K from the largest observed mark. Prefer the process method (or explicit K) to retain unobserved types. All-empty input requires an explicit K. Simulated pairs retain their observation end; plain pairs default to the last event. An explicit t_end overrides either.
- easy_tpp.simulation.write_splits(records, out_dir, splits=None)#
Write consecutive, disjoint splits as <split>.json JSON lines.
Values must all be integer counts summing to len(records), or fractions summing to one. Fractional rounding remainder goes to the final split. Defaults to train/dev/test fractions 0.8/0.1/0.1; no implicit shuffle. Returns a mapping of split names to Paths.