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.

Renewal Temporal Point Process — From Scratch and With NumPyro

Open In Colab

A renewal process has i.i.d. inter-event gaps Δti∼F\Delta t_i \sim F on [0,T][0, T]. With density ff and survival S=1−FS = 1 - F, the joint log-likelihood of events {t1,…,tn}\{t_1, \dots, t_n\} is

log⁡L=∑i=1nlog⁡f(Δti)+log⁡S(T−tn).\log L = \sum_{i=1}^n \log f(\Delta t_i) + \log S(T - t_n).

When F=Exp(λ)F = \mathrm{Exp}(\lambda) this collapses to an HPP. Picking Gamma(k,λ)\mathrm{Gamma}(k, \lambda) with k>1k > 1 gives regular (sub-Poisson) sequences; k<1k < 1 gives bursty ones. This notebook walks through both sides of the API:

  1. From scratch — direct use of the primitives renewal_log_prob, renewal_sample.

  2. With NumPyro — the RenewalProcess distribution wrapper + NUTS inference for the inter-event parameters.

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. From Scratch: Primitives

Three inter-event laws with the same mean = 1 so we can compare shapes directly.

<Figure size 900x500 with 3 Axes>

Hazard functions show the shape differences: Exponential is flat, regular Gamma is increasing (memory “builds up”), bursty Gamma is decreasing (clustered events).

<Figure size 700x400 with 1 Axes>

Log-likelihood sanity check

For Exponential inter-events the renewal log-prob equals the HPP log-prob exactly — a cross-family invariant we use to smoke-test the primitive.

renewal = -5.1882  hpp = -5.1882  diff = 4.77e-07

2. With NumPyro: Inference

Given observations from a Gamma(k=2, λ=1.5) renewal process, recover the posterior over (k,λ)(k, \lambda) with NUTS.

observed 57 events on [0, 80.0] — expected ~ 60.0
posterior k       = 1.930 ± 0.292  (truth 2.0)
posterior rate    = 1.353 ± 0.245  (truth 1.5)
<Figure size 900x350 with 2 Axes>

Both parameters are well identified from ~120 events; the regular-Gamma shape k=2k=2 is recovered despite the prior being centred at 1.