Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Thinning / Observation-Operator TPP — From Scratch and With NumPyro

Open In Colab

Thinning is the TPP analogue of an observation operator. A base process with intensity λbase(t∣H)\lambda_\text{base}(t \mid \mathcal{H}) is passed through a retention function p(t∣H,m)∈[0,1]p(t \mid \mathcal{H}, m) \in [0, 1] that decides — per event — whether each one is recorded. The thinned process has intensity

λthin(t∣H)=p(t∣H)⋅λbase(t∣H),\lambda_\text{thin}(t \mid \mathcal{H}) = p(t \mid \mathcal{H}) \cdot \lambda_\text{base}(t \mid \mathcal{H}),

and log-likelihood (for the retained events)

log⁡L=log⁡Lbase({ti})+∑ilog⁡p(ti∣Hi)−∫0T(1−p(t∣H)) λbase(t∣H) dt.\log L = \log L_\text{base}(\{t_i\}) + \sum_i \log p(t_i \mid \mathcal{H}_i) - \int_0^T \big(1 - p(t \mid \mathcal{H})\big)\, \lambda_\text{base}(t \mid \mathcal{H})\, dt.

This notebook shows:

  1. Generic thinning primitive (thinning_sample) — simulate IPP, Hawkes, or any history-dependent TPP with a single routine.

  2. ThinningProcess operator + NumPyro — build a learnable observation operator (a logistic detector), observe the thinned events, and recover both the base process and the detector parameters jointly with NUTS.

Setup

/home/azureuser/localfiles/xtremax/.venv/bin/python: No module named pip
Note: you may need to restart the kernel to use updated packages.
/home/azureuser/localfiles/xtremax/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

1. Generic Thinning Primitive

thinning_sample takes (conditional_intensity_fn, lambda_max_fn) both operating on an EventHistory. The same primitive reproduces an IPP and a Hawkes process.

Using it for an IPP: constant upper bound, history-free intensity.

IPP sample: n = 38

Using it for a Hawkes process: intensity depends on history, λ_bar = μ + αN(t).

Hawkes sample: n = 31, expected ~ 16.7

2. Learnable Observation Operator

Scenario: an instrument observes a latent Hawkes process but its detection probability grows logistically with a learnable threshold. The observed sequence is the thinned process; the latent sequence is unobserved.

Goal: recover both the Hawkes parameters and the detector parameters with NUTS.

observed events: 17

Plot the detector sensitivity curve over time.

<Figure size 900x350 with 1 Axes>

NUTS: recover Hawkes + detector parameters jointly

mu     posterior = 0.458 ± 0.083  (truth 0.6)
alpha  posterior = 0.351 ± 0.112  (truth 0.4)
beta   posterior = 0.743 ± 0.314  (truth 1.0)
scale  posterior = 1.452 ± 0.540  (truth 0.3)
t0     posterior = -1.731 ± 1.539  (truth 6.0)

The detector warm-up time t0t_0 and steepness scale are identified, and the underlying Hawkes branching ratio α/β\alpha/\beta is recovered. Thinning-of-Hawkes is a practical template for modelling “hidden detector + latent self-exciting process” scenarios without marginalising out the latent events by hand.

<Figure size 1500x300 with 5 Axes>