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.

Marked Spatial Point Process — From Scratch and With NumPyro

Open In Colab

A marked spatial point process pairs each event location with a mark — a magnitude, type, size, or any other random attribute attached to the point. Common examples:

  • tree locations + diameters,

  • earthquake epicentres + magnitudes (Gutenberg–Richter),

  • crime events + severity codes,

  • methane plumes + emission rates.

Under the separable factorisation λ(s,m)=λ(s) f(m∣s)\lambda(s, m) = \lambda(s)\, f(m \mid s), the joint log-likelihood splits into a ground-process term and a mark term:

log⁡L=∑i=1nlog⁡λ(si)+∑i=1nlog⁡f(mi∣si)−Λ(D).\log L = \sum_{i=1}^n \log \lambda(s_i) + \sum_{i=1}^n \log f(m_i \mid s_i) - \Lambda(D).

xtremax’s MarkedSpatialPP is exactly this: a ground operator (homogeneous or inhomogeneous spatial PP) plus a user-supplied mark distribution callable. Marks can be scalar, vector, discrete, or location-dependent — anything a numpyro.distributions.Distribution can express.

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. Independent marks: trees with random diameters

The simplest marked process: locations from a homogeneous spatial PP, marks i.i.d. Gamma. The mark distribution callable ignores its input and just returns the same Gamma for every event.

Sampled 38 trees, mean diameter = 2.59 m
<Figure size 500x500 with 2 Axes>

The joint log-likelihood decomposes — and we can score the ground and mark terms separately.

joint log L = -308.11  =  ground -251.34 + marks -56.77

2. Location-dependent marks: earthquakes along a fault line

Now make the mark law depend on space. Earthquake magnitudes follow Gutenberg–Richter — Exponential with a bb-value parameter — but suppose the bb-value is smaller (heavier-tailed magnitudes) closer to the fault. We’ll use an inhomogeneous spatial PP whose intensity is concentrated along a diagonal fault, and an Exponential mark with rate inversely proportional to distance from that fault.

Sampled 932 earthquakes, max magnitude = 7.03
<Figure size 600x550 with 2 Axes>

Sanity check: events near the fault should have higher mean magnitude than events far from it (lower b-value → heavier tail).

Mean magnitude within 10 km of fault: 0.851
Mean magnitude beyond 30 km of fault: 0.695

3. With NumPyro — joint inference over ground rate and mark scale

Treat both the ground rate λ\lambda and the mark scale parameter as latent. The joint log-likelihood means a single NUTS run gives us a coherent posterior over both.

Synthetic observation: 29 events

                          mean       std    median      5.0%     95.0%     n_eff     r_hat
  mark_concentration      4.06      0.89      3.99      2.78      5.60    291.15      1.00
           mark_rate      1.42      0.33      1.39      0.89      1.91    293.28      1.00
                rate      0.30      0.06      0.30      0.21      0.39    539.76      1.00

Number of divergences: 0

All three posteriors should concentrate near the truth. The ground rate is informed only by the count, the Gamma parameters only by the magnitudes — the separable factorisation makes each subset of parameters an essentially independent posterior block (modulo whatever prior coupling we impose).

<Figure size 1200x350 with 3 Axes>

Where to go from here

  • Vector or discrete marks. Swap the mark distribution for MultivariateNormal (vector marks), Categorical (event types), or Pareto (heavy-tailed magnitudes). The factorisation and the API don’t change.

  • Joint posterior over intensity and mark hyperparameters. Using InhomogeneousSpatialPP as the ground process, you can infer both the spatial peak location and a magnitude-decay rate in a single NUTS run.

  • Higher dimensions. As with the unmarked spatial PPs, mark inference works for d∈{1,2,3,…}d \in \{1, 2, 3, \ldots\} — the mark distribution callable just consumes the location’s full dd-vector.