Skip to main content

rjdoa

Bayesian wideband direction-of-arrival (DoA) estimation and source detection with reversible-jump samplers. The number of sources and their bearings are inferred jointly from time-domain array data, with the source signals and noise power marginalised out [1], [2].

The package is a Python port of ReversibleJump.jl (v0.2.0) and WidebandDoA.jl, verified against the Julia code. It adds the reversible-jump SMC samplers of Bright and Maskell [3].

The primary and intended purpose for this repository is compatibility for inclusion into the blue-pebble sonar signal processing simulator plugin for Stone Soup.

pip install -e ".[dev]"
pytest -m "not slow"            # unit + Julia fixture parity (~1.5 min)
pytest -m slow                  # Julia chain parity + Geweke tests (several min, all cores)

Layout

rjdoa.estimate(signals, fs, positions, c, method=...) is the one-call entry point. It takes one window of array data in blue-pebble's layout, runs nRJMCMC (optionally as several chains in parallel), RJSMC or wiRJSMC and returns the posterior number of sources, bearings, their uncertainty, how often each appears and, for nRJMCMC, convergence diagnostics.

All modules are under rjdoa:

  • reversible_jump has RJMCMC and nRJMCMC with independent and annealed (AIS) jump proposals, a runner for independent chains in parallel, and R-hat and ESS diagnostics.
  • reversible_jump.smc has RJSMC and wiRJSMC, run serially or in parallel processes.
  • doa has the wideband model, the collapsed likelihood (numba and numpy), array geometries, relabelling, simulation and plotting.
  • doa.inference has the slice and Metropolis kernels.
  • mixture has the Richardson-Green Gaussian mixture used to reproduce [3].
  • dists has fast scalar log-densities with Distributions.jl parametrisations.

DoA parameters are (k, 2) arrays of [phi, loglambda], and example scripts are in scripts/.

Results

Performance

On the demo configuration (M = 20, N = 64, n_fft = 128) the log-density is 1.6-6.3x faster than Julia for k = 1-6, and the nRJMCMC demo sampler takes 267 us per iteration against Julia's 1165 us. Only the single-source slice sweep is slower (261 us against 157 us). Timings come from scripts/bench_python.py and verification/julia/bench.jl.

DoA: nRJMCMC vs RJSMC

These results come from scripts/rjsmc_doa.py on the demo scenario, with true DoAs of 30, 45, -15 and -60 degrees, where the 30 degree source is weak. All four samplers place the four bearings within 0.1 degrees of each other.

method wall (s) P(k=3) P(k=4) mean k R-hat of k
nRJMCMC (1 chain x 100k) 30.8 0.60 0.39 3.40 1.00
nRJMCMC (16 chains x 10k, in parallel) 4.2 0.63 0.37 3.37 1.04
RJSMC (N=128, T=300) 9.8 0.40 0.58 3.62 -
wiRJSMC 9.5 0.20 0.80 3.80 -

The 16 parallel chains start from random draws of the prior, yet agree with the single chain and the Julia reference chains in about a seventh of the time, while the SMC order posteriors disagree. This needs further testing (see Notes / TODO). Currently nRJMCMC appears to be more accurate for P(k).

DoA overview

Model-order trace, order posterior and DoA posterior (left to right) for each sampler.

Sampler benchmark

scripts/benchmark/ compares each sampler's error, for a fixed wall time, against long reference runs on four synthetic scenarios (detailed in scripts/benchmark/README.md). Parallel nRJMCMC chains are the most accurate in every scenario, and 4 or more chains give similar results. RJSMC and wiRJSMC overestimate the number of sources on the two harder scenarios, by 0.08 to 0.55, and more time or particles do not reduce this.

Error against time

TV error of P(k) against wall time, mean and range over 5 seeds, for each scenario.

RJSMC paper reproduction

These results come from scripts/rjsmc_mixture.py, with N = 128 particles, T = 1000 iterations and 32 cores.

data method wall (s) BIC variance mode k
toy nRJMCMC (128k iterations) 18.5 54.7 2
toy RJSMC 6.8 (39.4 on 1 core) 79.3 2
toy wiRJSMC 6.4 31.1 2
galaxy nRJMCMC 24.1 263 3
galaxy RJSMC 9.2 (62.4 on 1 core) 387 4
galaxy wiRJSMC 7.5 49.6 4

As in [3], wiRJSMC has the lowest BIC variance, but this compares single nRJMCMC draws with per-iteration SMC averages. If nRJMCMC is averaged similarly, its variance is lowest. RJSMC still runs 2.5-3x faster than nRJMCMC here. The larger 30x gain in [3] is measured against a much slower baseline (5417 s for 128k nRJMCMC iterations, against 18.5 s here) on 64 cores rather than 32. Models with costlier particles than this mixture should scale closer to [3].

The SMC BIC variances on the toy data closely match [3] (79 and 31 here, against 74 and 28). Other values, such as BIC levels and numbers of components, differ because [3] does not fully specify its priors.

Galaxy traces

Weighted-mean BIC and number of components for the galaxy data, against model evaluations.

Verification and deviations from the originals

The port matches the Julia code to 1e-9 on deterministic outputs and agrees with Julia chains on order posteriors, DoA means and acceptance rates (|z| < 2). Every sampler also passes exact-target and Geweke joint-distribution tests. verification/julia/setup.sh builds the Julia reference environment.

The port deliberately differs from the Julia code in three places:

  • The Julia simulator draws the noise level from a different prior than the one the likelihood assumes. The port's simulator uses the same prior as the likelihood.
  • In arithmetic-path AIS, Julia lets proposed DoAs leave the range the proposal can reach, which biases P(k) low. The port rejects such proposals.
  • When nRJMCMC is moving down at k = 0, Julia proposes a birth, which samples the wrong distribution. The port reverses direction instead.

Notes / TODO

  • The likelihood treats the zero padding as measured silence, so a signal present at a window edge leaves about D samples per edge that no plane wave explains (D is the delay across the array). At high SNR this adds weak spurious sources (P(k>4) = 0.61 / 0.18 / 0.06 at N = 64 / 256 / 1024, +10 dB). Integrating the padded samples out as missing data would fix it; until then, keep D/N small.
  • RJSMC and wiRJSMC overestimate the number of sources. Their weights collapse every iteration (ESS about 10 % of N, as almost every jump proposal is poor). More particles do not help, so the cause is not clear. Need to test: much longer SMC runs and SMC started from posterior draws.
  • Data-driven birth proposals (bearings drawn from where the data has unexplained power) would raise jump acceptance for every sampler, and SMC most.

References

[1] K. Kim, P. T. Clemson, J. P. Reilly, J. F. Ralph, and S. Maskell, "Fully Bayesian wideband direction-of-arrival estimation and detection via RJMCMC," arXiv:2412.08895, Dec. 2024.

[2] K. Kim, P. T. Clemson, J. P. Reilly, J. F. Ralph, and S. Maskell, "Bayesian wideband signal detection via source signal marginalization and RJMCMC," IEEE Trans. Signal Process., vol. 74, pp. 3773-3788, 2026, doi: 10.1109/TSP.2026.3721253.

[3] M. Bright and S. Maskell, "Reversible jump SMC," in Proc. IEEE 10th Int. Workshop Comput. Adv. Multi-Sensor Adaptive Process. (CAMSAP), 2025, pp. 271-275, doi: 10.1109/CAMSAP66162.2025.11423972.

Metadata

Release files for rjdoa 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rjdoa 0.2.0
File Size Uploaded Provenance Actions
rjdoa-0.2.0.tar.gz 68.5 kB With provenance Details for rjdoa-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rjdoa 0.2.0
File Interpreter ABI Platform Actions
rjdoa-0.2.0-py3-none-any.whl Python 3 none any Details for rjdoa-0.2.0-py3-none-any.whl

Total release size: 150.6 kB

Release files / rjdoa-0.2.0.tar.gz

Download URL rjdoa-0.2.0.tar.gz
Size 68.5 kB
Tags Source
SHA-256 checksum
How to use checksums
abab6d529a359ae46f75a070e3b3f3562c40dbbcb91a9bf04f9ceab734f7e2cd
BLAKE2b-256 checksum
How to use checksums
3e29638f475a8f3439982fe265284d37e0911301ef7398f0f982cf40262c0e16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / rjdoa-0.2.0-py3-none-any.whl

Download URL rjdoa-0.2.0-py3-none-any.whl
Size 82.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7e304c5def791aea51079b108b4d89f0b0a13f6b445f210fc9ad82133105ba9
BLAKE2b-256 checksum
How to use checksums
6d06d8c3a7b8d893e7f1f34e26f7d62fed7f1db216b308965f628bc7afc7da32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for rjdoa 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rjdoa-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page