Skip to content

Add spatial randomization and rate-of-approach pair distribution functions - #598

Open
M-Colley wants to merge 1 commit into
PedestrianDynamics:mainfrom
M-Colley:feat/pair-distribution-approach-rate-and-spatial-randomization
Open

M-Colley wants to merge 1 commit into
PedestrianDynamics:mainfrom
M-Colley:feat/pair-distribution-approach-rate-and-spatial-randomization

Conversation

@M-Colley

Copy link
Copy Markdown

Summary

Fixes #327
Fixes #333

Extends pedpy.methods.spatial_analysis (and top-level pedpy exports) with uniform spatial randomization for static/semi-static crowds and rate-of-approach pair-distribution analysis:

  • Spatial randomization normalization (add a normalization method with "random spatial distribution" in pdf #327): Adds PairNormalizationMethod (TIME_RANDOMIZATION default, SPATIAL_RANDOMIZATION) and optional walkable_area / seed parameters to compute_pair_distribution_function. Under SPATIAL_RANDOMIZATION, non-interacting reference positions are sampled uniformly inside walkable_area.polygon (respecting interior obstacles/holes), avoiding the degenerate self-overlap of frame shuffling in dense static or semi-static crowds.
  • Rate-of-approach pair distribution (Computation of the pdf for the "rate of approach" #333): Adds compute_approach_rate_pair_distribution evaluating pairwise approach rate {ij} = -\frac{dr_{ij}}{dt} = -\frac{(\vec{x}_i - \vec{x}_j) \cdot (\vec{v}_i - \vec{v}_j)}{|\vec{x}i - \vec{x}j|}$ following Karamouzas et al. (2014, doi:10.1103/PhysRevLett.113.238701) and Cordes et al. (2024, doi:10.1093/pnasnexus/pgae120), supporting both the 1D distribution (v) = P(v) / P{\mathrm{NI}}(v)$ and the 2D distance / approach-rate distribution (r, v) = P(r, v) / P{\mathrm{NI}}(r, v)$ with either TIME_RANDOMIZATION or SPATIAL_RANDOMIZATION.
  • Scoped warning handling: Replaces global warnings.filterwarnings(default) resets with np.errstate + explicit zero-bin warning checks so caller warning filters are preserved.

@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.25974% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.23%. Comparing base (0604d9a) to head (d94a5a6).

Files with missing lines Patch % Lines
pedpy/methods/spatial_analysis.py 90.19% 15 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Computation of the pdf for the "rate of approach" add a normalization method with "random spatial distribution" in pdf

1 participant