rjdoa 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. rjdoa-0.2.0/LICENSE +27 -0
  2. rjdoa-0.2.0/PKG-INFO +194 -0
  3. rjdoa-0.2.0/README.md +153 -0
  4. rjdoa-0.2.0/pyproject.toml +71 -0
  5. rjdoa-0.2.0/rjdoa/__init__.py +22 -0
  6. rjdoa-0.2.0/rjdoa/dists.py +518 -0
  7. rjdoa-0.2.0/rjdoa/doa/__init__.py +25 -0
  8. rjdoa-0.2.0/rjdoa/doa/estimate.py +442 -0
  9. rjdoa-0.2.0/rjdoa/doa/filters.py +117 -0
  10. rjdoa-0.2.0/rjdoa/doa/geometry.py +363 -0
  11. rjdoa-0.2.0/rjdoa/doa/inference/__init__.py +17 -0
  12. rjdoa-0.2.0/rjdoa/doa/inference/gibbs.py +133 -0
  13. rjdoa-0.2.0/rjdoa/doa/inference/metropolis.py +183 -0
  14. rjdoa-0.2.0/rjdoa/doa/inference/slice.py +321 -0
  15. rjdoa-0.2.0/rjdoa/doa/likelihood.py +344 -0
  16. rjdoa-0.2.0/rjdoa/doa/model.py +464 -0
  17. rjdoa-0.2.0/rjdoa/doa/plotting.py +160 -0
  18. rjdoa-0.2.0/rjdoa/doa/prior.py +105 -0
  19. rjdoa-0.2.0/rjdoa/doa/reconstruct.py +91 -0
  20. rjdoa-0.2.0/rjdoa/doa/relabel.py +447 -0
  21. rjdoa-0.2.0/rjdoa/doa/simulate.py +115 -0
  22. rjdoa-0.2.0/rjdoa/doa/striped.py +53 -0
  23. rjdoa-0.2.0/rjdoa/mixture/__init__.py +20 -0
  24. rjdoa-0.2.0/rjdoa/mixture/data.py +84 -0
  25. rjdoa-0.2.0/rjdoa/mixture/kernels.py +93 -0
  26. rjdoa-0.2.0/rjdoa/mixture/model.py +220 -0
  27. rjdoa-0.2.0/rjdoa/mixture/moves.py +303 -0
  28. rjdoa-0.2.0/rjdoa/reversible_jump/__init__.py +30 -0
  29. rjdoa-0.2.0/rjdoa/reversible_jump/_math.py +82 -0
  30. rjdoa-0.2.0/rjdoa/reversible_jump/ais.py +225 -0
  31. rjdoa-0.2.0/rjdoa/reversible_jump/diagnostics.py +145 -0
  32. rjdoa-0.2.0/rjdoa/reversible_jump/jump.py +74 -0
  33. rjdoa-0.2.0/rjdoa/reversible_jump/moves.py +239 -0
  34. rjdoa-0.2.0/rjdoa/reversible_jump/multichain.py +215 -0
  35. rjdoa-0.2.0/rjdoa/reversible_jump/nrjmcmc.py +122 -0
  36. rjdoa-0.2.0/rjdoa/reversible_jump/proposals.py +45 -0
  37. rjdoa-0.2.0/rjdoa/reversible_jump/protocols.py +51 -0
  38. rjdoa-0.2.0/rjdoa/reversible_jump/rjmcmc.py +172 -0
  39. rjdoa-0.2.0/rjdoa/reversible_jump/sample.py +78 -0
  40. rjdoa-0.2.0/rjdoa/reversible_jump/smc.py +600 -0
  41. rjdoa-0.2.0/rjdoa/reversible_jump/state.py +53 -0
  42. rjdoa-0.2.0/rjdoa.egg-info/PKG-INFO +194 -0
  43. rjdoa-0.2.0/rjdoa.egg-info/SOURCES.txt +45 -0
  44. rjdoa-0.2.0/rjdoa.egg-info/dependency_links.txt +1 -0
  45. rjdoa-0.2.0/rjdoa.egg-info/requires.txt +21 -0
  46. rjdoa-0.2.0/rjdoa.egg-info/top_level.txt +1 -0
  47. rjdoa-0.2.0/setup.cfg +4 -0
rjdoa-0.2.0/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Finley Boulton
4
+
5
+ rjdoa is a Python port of ReversibleJump.jl and WidebandDoA.jl, which are distributed
6
+ under the MIT License with the following copyright notices:
7
+
8
+ Copyright (c) 2023 Ray Kim <msca8h@naver.com> and contributors (ReversibleJump.jl)
9
+ Copyright (c) 2023-2024 Kyurae Kim <kyrkim@seas.upenn.edu> and contributors (WidebandDoA.jl)
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
rjdoa-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: rjdoa
3
+ Version: 0.2.0
4
+ Summary: Bayesian wideband DoA estimation and detection with reversible-jump MCMC and SMC samplers.
5
+ Author: Finley Boulton
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/fincb/rjdoa
8
+ Project-URL: Bug Tracker, https://github.com/fincb/rjdoa/issues
9
+ Keywords: direction of arrival,passive sonar,source detection,Bayesian inference,reversible jump MCMC,sequential Monte Carlo
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.26
24
+ Requires-Dist: scipy>=1.11
25
+ Requires-Dist: numba>=0.59
26
+ Requires-Dist: tqdm>=4
27
+ Provides-Extra: plot
28
+ Requires-Dist: matplotlib>=3.7; extra == "plot"
29
+ Provides-Extra: scripts
30
+ Requires-Dist: matplotlib>=3.7; extra == "scripts"
31
+ Requires-Dist: h5py>=3; extra == "scripts"
32
+ Provides-Extra: test
33
+ Requires-Dist: pytest>=7; extra == "test"
34
+ Requires-Dist: h5py>=3; extra == "test"
35
+ Provides-Extra: dev
36
+ Requires-Dist: rjdoa[scripts,test]; extra == "dev"
37
+ Requires-Dist: ruff; extra == "dev"
38
+ Requires-Dist: build; extra == "dev"
39
+ Requires-Dist: twine; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # rjdoa
43
+
44
+ Bayesian wideband direction-of-arrival (DoA) estimation and source detection with
45
+ reversible-jump samplers. The number of sources and their bearings are inferred jointly from
46
+ time-domain array data, with the source signals and noise power marginalised out [1], [2].
47
+
48
+ The package is a Python port of [ReversibleJump.jl](https://github.com/Red-Portal/ReversibleJump.jl) (v0.2.0) and
49
+ [WidebandDoA.jl](https://github.com/Red-Portal/WidebandDoA.jl), verified against the Julia code. It adds the
50
+ reversible-jump SMC samplers of Bright and Maskell [3].
51
+
52
+ The primary and intended purpose for this repository is compatibility for inclusion into the
53
+ [blue-pebble](https://github.com/UoL-SignalProcessingGroup/blue-pebble) sonar signal processing simulator
54
+ plugin for [Stone Soup](https://github.com/dstl/Stone-Soup).
55
+
56
+ ```
57
+ pip install -e ".[dev]"
58
+ pytest -m "not slow" # unit + Julia fixture parity (~1.5 min)
59
+ pytest -m slow # Julia chain parity + Geweke tests (several min, all cores)
60
+ ```
61
+
62
+ ## Layout
63
+
64
+ `rjdoa.estimate(signals, fs, positions, c, method=...)` is the one-call entry point. It takes
65
+ one window of array data in blue-pebble's layout, runs nRJMCMC (optionally as several chains in
66
+ parallel), RJSMC or wiRJSMC and returns the posterior number of sources, bearings, their
67
+ uncertainty, how often each appears and, for nRJMCMC, convergence diagnostics.
68
+
69
+ All modules are under `rjdoa`:
70
+
71
+ - `reversible_jump` has RJMCMC and nRJMCMC with independent and annealed (AIS) jump proposals,
72
+ a runner for independent chains in parallel, and R-hat and ESS diagnostics.
73
+ - `reversible_jump.smc` has RJSMC and wiRJSMC, run serially or in parallel processes.
74
+ - `doa` has the wideband model, the collapsed likelihood (numba and numpy), array geometries,
75
+ relabelling, simulation and plotting.
76
+ - `doa.inference` has the slice and Metropolis kernels.
77
+ - `mixture` has the Richardson-Green Gaussian mixture used to reproduce [3].
78
+ - `dists` has fast scalar log-densities with Distributions.jl parametrisations.
79
+
80
+ DoA parameters are `(k, 2)` arrays of `[phi, loglambda]`, and example scripts are in
81
+ `scripts/`.
82
+
83
+ ## Results
84
+
85
+ ### Performance
86
+
87
+ On the demo configuration (M = 20, N = 64, n_fft = 128) the log-density is 1.6-6.3x faster
88
+ than Julia for k = 1-6, and the nRJMCMC demo sampler takes 267 us per iteration against
89
+ Julia's 1165 us. Only the single-source slice sweep is slower (261 us against 157 us). Timings
90
+ come from `scripts/bench_python.py` and `verification/julia/bench.jl`.
91
+
92
+ ### DoA: nRJMCMC vs RJSMC
93
+
94
+ These results come from `scripts/rjsmc_doa.py` on the demo scenario, with true DoAs of 30, 45,
95
+ -15 and -60 degrees, where the 30 degree source is weak. All four samplers place the four
96
+ bearings within 0.1 degrees of each other.
97
+
98
+ | method | wall (s) | P(k=3) | P(k=4) | mean k | R-hat of k |
99
+ |---|---|---|---|---|---|
100
+ | nRJMCMC (1 chain x 100k) | 30.8 | 0.60 | 0.39 | 3.40 | 1.00 |
101
+ | nRJMCMC (16 chains x 10k, in parallel) | 4.2 | 0.63 | 0.37 | 3.37 | 1.04 |
102
+ | RJSMC (N=128, T=300) | 9.8 | 0.40 | 0.58 | 3.62 | - |
103
+ | wiRJSMC | 9.5 | 0.20 | 0.80 | 3.80 | - |
104
+
105
+ The 16 parallel chains start from random draws of the prior, yet agree with the single chain
106
+ and the Julia reference chains in about a seventh of the time, while the SMC order posteriors
107
+ disagree. This needs further testing (see [Notes / TODO](#notes--todo)). Currently nRJMCMC
108
+ appears to be more accurate for P(k).
109
+
110
+ <img src="https://github.com/fincb/rjdoa/raw/master/scripts/out/doa_overview.png" width="800" alt="DoA overview">
111
+
112
+ *Model-order trace, order posterior and DoA posterior (left to right) for each sampler.*
113
+
114
+ ### Sampler benchmark
115
+
116
+ `scripts/benchmark/` compares each sampler's error, for a fixed wall time, against long
117
+ reference runs on four synthetic scenarios (detailed in `scripts/benchmark/README.md`).
118
+ Parallel nRJMCMC chains are the most accurate in every scenario, and 4 or more chains give
119
+ similar results. RJSMC and wiRJSMC overestimate the number of sources on the two harder
120
+ scenarios, by 0.08 to 0.55, and more time or particles do not reduce this.
121
+
122
+ <img src="https://github.com/fincb/rjdoa/raw/master/scripts/benchmark/out/error_vs_time.png" width="800" alt="Error against time">
123
+
124
+ *TV error of P(k) against wall time, mean and range over 5 seeds, for each scenario.*
125
+
126
+ ### RJSMC paper reproduction
127
+
128
+ These results come from `scripts/rjsmc_mixture.py`, with N = 128 particles, T = 1000
129
+ iterations and 32 cores.
130
+
131
+ | data | method | wall (s) | BIC variance | mode k |
132
+ |---|---|---|---|---|
133
+ | toy | nRJMCMC (128k iterations) | 18.5 | 54.7 | 2 |
134
+ | toy | RJSMC | 6.8 (39.4 on 1 core) | 79.3 | 2 |
135
+ | toy | wiRJSMC | 6.4 | 31.1 | 2 |
136
+ | galaxy | nRJMCMC | 24.1 | 263 | 3 |
137
+ | galaxy | RJSMC | 9.2 (62.4 on 1 core) | 387 | 4 |
138
+ | galaxy | wiRJSMC | 7.5 | 49.6 | 4 |
139
+
140
+ As in [3], wiRJSMC has the lowest BIC variance, but this compares single nRJMCMC draws with
141
+ per-iteration SMC averages. If nRJMCMC is averaged similarly, its variance is lowest. RJSMC
142
+ still runs 2.5-3x faster than nRJMCMC here. The larger 30x gain in [3] is measured against a
143
+ much slower baseline (5417 s for 128k nRJMCMC iterations, against 18.5 s here) on 64 cores
144
+ rather than 32. Models with costlier particles than this mixture should scale closer to [3].
145
+
146
+ The SMC BIC variances on the toy data closely match [3] (79 and 31 here, against 74 and 28).
147
+ Other values, such as BIC levels and numbers of components, differ because [3] does not fully
148
+ specify its priors.
149
+
150
+ <img src="https://github.com/fincb/rjdoa/raw/master/scripts/out/mixture_galaxy_traces.png" width="800" alt="Galaxy traces">
151
+
152
+ *Weighted-mean BIC and number of components for the galaxy data, against model evaluations.*
153
+
154
+ ## Verification and deviations from the originals
155
+
156
+ The port matches the Julia code to 1e-9 on deterministic outputs and agrees with Julia chains
157
+ on order posteriors, DoA means and acceptance rates (|z| < 2). Every sampler also passes
158
+ exact-target and Geweke joint-distribution tests. `verification/julia/setup.sh` builds the
159
+ Julia reference environment.
160
+
161
+ The port deliberately differs from the Julia code in three places:
162
+
163
+ - The Julia simulator draws the noise level from a different prior than the one the likelihood
164
+ assumes. The port's simulator uses the same prior as the likelihood.
165
+ - In arithmetic-path AIS, Julia lets proposed DoAs leave the range the proposal can reach,
166
+ which biases P(k) low. The port rejects such proposals.
167
+ - When nRJMCMC is moving down at k = 0, Julia proposes a birth, which samples the wrong
168
+ distribution. The port reverses direction instead.
169
+
170
+ ## Notes / TODO
171
+
172
+ - The likelihood treats the zero padding as measured silence, so a signal present at a window
173
+ edge leaves about D samples per edge that no plane wave explains (D is the delay across the
174
+ array). At high SNR this adds weak spurious sources (P(k>4) = 0.61 / 0.18 / 0.06 at
175
+ N = 64 / 256 / 1024, +10 dB). Integrating the padded samples out as missing data would fix
176
+ it; until then, keep D/N small.
177
+ - RJSMC and wiRJSMC overestimate the number of sources. Their weights collapse every iteration
178
+ (ESS about 10 % of N, as almost every jump proposal is poor). More particles do not help,
179
+ so the cause is not clear. Need to test: much longer SMC runs and SMC started from posterior draws.
180
+ - Data-driven birth proposals (bearings drawn from where the data has unexplained power) would
181
+ raise jump acceptance for every sampler, and SMC most.
182
+
183
+ ## References
184
+
185
+ [1] K. Kim, P. T. Clemson, J. P. Reilly, J. F. Ralph, and S. Maskell, "Fully Bayesian wideband
186
+ direction-of-arrival estimation and detection via RJMCMC," arXiv:2412.08895, Dec. 2024.
187
+
188
+ [2] K. Kim, P. T. Clemson, J. P. Reilly, J. F. Ralph, and S. Maskell, "Bayesian wideband signal
189
+ detection via source signal marginalization and RJMCMC," *IEEE Trans. Signal Process.*,
190
+ vol. 74, pp. 3773-3788, 2026, doi: 10.1109/TSP.2026.3721253.
191
+
192
+ [3] M. Bright and S. Maskell, "Reversible jump SMC," in *Proc. IEEE 10th Int. Workshop Comput.
193
+ Adv. Multi-Sensor Adaptive Process. (CAMSAP)*, 2025, pp. 271-275,
194
+ doi: 10.1109/CAMSAP66162.2025.11423972.
rjdoa-0.2.0/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # rjdoa
2
+
3
+ Bayesian wideband direction-of-arrival (DoA) estimation and source detection with
4
+ reversible-jump samplers. The number of sources and their bearings are inferred jointly from
5
+ time-domain array data, with the source signals and noise power marginalised out [1], [2].
6
+
7
+ The package is a Python port of [ReversibleJump.jl](https://github.com/Red-Portal/ReversibleJump.jl) (v0.2.0) and
8
+ [WidebandDoA.jl](https://github.com/Red-Portal/WidebandDoA.jl), verified against the Julia code. It adds the
9
+ reversible-jump SMC samplers of Bright and Maskell [3].
10
+
11
+ The primary and intended purpose for this repository is compatibility for inclusion into the
12
+ [blue-pebble](https://github.com/UoL-SignalProcessingGroup/blue-pebble) sonar signal processing simulator
13
+ plugin for [Stone Soup](https://github.com/dstl/Stone-Soup).
14
+
15
+ ```
16
+ pip install -e ".[dev]"
17
+ pytest -m "not slow" # unit + Julia fixture parity (~1.5 min)
18
+ pytest -m slow # Julia chain parity + Geweke tests (several min, all cores)
19
+ ```
20
+
21
+ ## Layout
22
+
23
+ `rjdoa.estimate(signals, fs, positions, c, method=...)` is the one-call entry point. It takes
24
+ one window of array data in blue-pebble's layout, runs nRJMCMC (optionally as several chains in
25
+ parallel), RJSMC or wiRJSMC and returns the posterior number of sources, bearings, their
26
+ uncertainty, how often each appears and, for nRJMCMC, convergence diagnostics.
27
+
28
+ All modules are under `rjdoa`:
29
+
30
+ - `reversible_jump` has RJMCMC and nRJMCMC with independent and annealed (AIS) jump proposals,
31
+ a runner for independent chains in parallel, and R-hat and ESS diagnostics.
32
+ - `reversible_jump.smc` has RJSMC and wiRJSMC, run serially or in parallel processes.
33
+ - `doa` has the wideband model, the collapsed likelihood (numba and numpy), array geometries,
34
+ relabelling, simulation and plotting.
35
+ - `doa.inference` has the slice and Metropolis kernels.
36
+ - `mixture` has the Richardson-Green Gaussian mixture used to reproduce [3].
37
+ - `dists` has fast scalar log-densities with Distributions.jl parametrisations.
38
+
39
+ DoA parameters are `(k, 2)` arrays of `[phi, loglambda]`, and example scripts are in
40
+ `scripts/`.
41
+
42
+ ## Results
43
+
44
+ ### Performance
45
+
46
+ On the demo configuration (M = 20, N = 64, n_fft = 128) the log-density is 1.6-6.3x faster
47
+ than Julia for k = 1-6, and the nRJMCMC demo sampler takes 267 us per iteration against
48
+ Julia's 1165 us. Only the single-source slice sweep is slower (261 us against 157 us). Timings
49
+ come from `scripts/bench_python.py` and `verification/julia/bench.jl`.
50
+
51
+ ### DoA: nRJMCMC vs RJSMC
52
+
53
+ These results come from `scripts/rjsmc_doa.py` on the demo scenario, with true DoAs of 30, 45,
54
+ -15 and -60 degrees, where the 30 degree source is weak. All four samplers place the four
55
+ bearings within 0.1 degrees of each other.
56
+
57
+ | method | wall (s) | P(k=3) | P(k=4) | mean k | R-hat of k |
58
+ |---|---|---|---|---|---|
59
+ | nRJMCMC (1 chain x 100k) | 30.8 | 0.60 | 0.39 | 3.40 | 1.00 |
60
+ | nRJMCMC (16 chains x 10k, in parallel) | 4.2 | 0.63 | 0.37 | 3.37 | 1.04 |
61
+ | RJSMC (N=128, T=300) | 9.8 | 0.40 | 0.58 | 3.62 | - |
62
+ | wiRJSMC | 9.5 | 0.20 | 0.80 | 3.80 | - |
63
+
64
+ The 16 parallel chains start from random draws of the prior, yet agree with the single chain
65
+ and the Julia reference chains in about a seventh of the time, while the SMC order posteriors
66
+ disagree. This needs further testing (see [Notes / TODO](#notes--todo)). Currently nRJMCMC
67
+ appears to be more accurate for P(k).
68
+
69
+ <img src="https://github.com/fincb/rjdoa/raw/master/scripts/out/doa_overview.png" width="800" alt="DoA overview">
70
+
71
+ *Model-order trace, order posterior and DoA posterior (left to right) for each sampler.*
72
+
73
+ ### Sampler benchmark
74
+
75
+ `scripts/benchmark/` compares each sampler's error, for a fixed wall time, against long
76
+ reference runs on four synthetic scenarios (detailed in `scripts/benchmark/README.md`).
77
+ Parallel nRJMCMC chains are the most accurate in every scenario, and 4 or more chains give
78
+ similar results. RJSMC and wiRJSMC overestimate the number of sources on the two harder
79
+ scenarios, by 0.08 to 0.55, and more time or particles do not reduce this.
80
+
81
+ <img src="https://github.com/fincb/rjdoa/raw/master/scripts/benchmark/out/error_vs_time.png" width="800" alt="Error against time">
82
+
83
+ *TV error of P(k) against wall time, mean and range over 5 seeds, for each scenario.*
84
+
85
+ ### RJSMC paper reproduction
86
+
87
+ These results come from `scripts/rjsmc_mixture.py`, with N = 128 particles, T = 1000
88
+ iterations and 32 cores.
89
+
90
+ | data | method | wall (s) | BIC variance | mode k |
91
+ |---|---|---|---|---|
92
+ | toy | nRJMCMC (128k iterations) | 18.5 | 54.7 | 2 |
93
+ | toy | RJSMC | 6.8 (39.4 on 1 core) | 79.3 | 2 |
94
+ | toy | wiRJSMC | 6.4 | 31.1 | 2 |
95
+ | galaxy | nRJMCMC | 24.1 | 263 | 3 |
96
+ | galaxy | RJSMC | 9.2 (62.4 on 1 core) | 387 | 4 |
97
+ | galaxy | wiRJSMC | 7.5 | 49.6 | 4 |
98
+
99
+ As in [3], wiRJSMC has the lowest BIC variance, but this compares single nRJMCMC draws with
100
+ per-iteration SMC averages. If nRJMCMC is averaged similarly, its variance is lowest. RJSMC
101
+ still runs 2.5-3x faster than nRJMCMC here. The larger 30x gain in [3] is measured against a
102
+ much slower baseline (5417 s for 128k nRJMCMC iterations, against 18.5 s here) on 64 cores
103
+ rather than 32. Models with costlier particles than this mixture should scale closer to [3].
104
+
105
+ The SMC BIC variances on the toy data closely match [3] (79 and 31 here, against 74 and 28).
106
+ Other values, such as BIC levels and numbers of components, differ because [3] does not fully
107
+ specify its priors.
108
+
109
+ <img src="https://github.com/fincb/rjdoa/raw/master/scripts/out/mixture_galaxy_traces.png" width="800" alt="Galaxy traces">
110
+
111
+ *Weighted-mean BIC and number of components for the galaxy data, against model evaluations.*
112
+
113
+ ## Verification and deviations from the originals
114
+
115
+ The port matches the Julia code to 1e-9 on deterministic outputs and agrees with Julia chains
116
+ on order posteriors, DoA means and acceptance rates (|z| < 2). Every sampler also passes
117
+ exact-target and Geweke joint-distribution tests. `verification/julia/setup.sh` builds the
118
+ Julia reference environment.
119
+
120
+ The port deliberately differs from the Julia code in three places:
121
+
122
+ - The Julia simulator draws the noise level from a different prior than the one the likelihood
123
+ assumes. The port's simulator uses the same prior as the likelihood.
124
+ - In arithmetic-path AIS, Julia lets proposed DoAs leave the range the proposal can reach,
125
+ which biases P(k) low. The port rejects such proposals.
126
+ - When nRJMCMC is moving down at k = 0, Julia proposes a birth, which samples the wrong
127
+ distribution. The port reverses direction instead.
128
+
129
+ ## Notes / TODO
130
+
131
+ - The likelihood treats the zero padding as measured silence, so a signal present at a window
132
+ edge leaves about D samples per edge that no plane wave explains (D is the delay across the
133
+ array). At high SNR this adds weak spurious sources (P(k>4) = 0.61 / 0.18 / 0.06 at
134
+ N = 64 / 256 / 1024, +10 dB). Integrating the padded samples out as missing data would fix
135
+ it; until then, keep D/N small.
136
+ - RJSMC and wiRJSMC overestimate the number of sources. Their weights collapse every iteration
137
+ (ESS about 10 % of N, as almost every jump proposal is poor). More particles do not help,
138
+ so the cause is not clear. Need to test: much longer SMC runs and SMC started from posterior draws.
139
+ - Data-driven birth proposals (bearings drawn from where the data has unexplained power) would
140
+ raise jump acceptance for every sampler, and SMC most.
141
+
142
+ ## References
143
+
144
+ [1] K. Kim, P. T. Clemson, J. P. Reilly, J. F. Ralph, and S. Maskell, "Fully Bayesian wideband
145
+ direction-of-arrival estimation and detection via RJMCMC," arXiv:2412.08895, Dec. 2024.
146
+
147
+ [2] K. Kim, P. T. Clemson, J. P. Reilly, J. F. Ralph, and S. Maskell, "Bayesian wideband signal
148
+ detection via source signal marginalization and RJMCMC," *IEEE Trans. Signal Process.*,
149
+ vol. 74, pp. 3773-3788, 2026, doi: 10.1109/TSP.2026.3721253.
150
+
151
+ [3] M. Bright and S. Maskell, "Reversible jump SMC," in *Proc. IEEE 10th Int. Workshop Comput.
152
+ Adv. Multi-Sensor Adaptive Process. (CAMSAP)*, 2025, pp. 271-275,
153
+ doi: 10.1109/CAMSAP66162.2025.11423972.
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rjdoa"
7
+ dynamic = ["version"]
8
+ description = "Bayesian wideband DoA estimation and detection with reversible-jump MCMC and SMC samplers."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Finley Boulton" }]
13
+ requires-python = ">=3.10"
14
+ dependencies = ["numpy>=1.26", "scipy>=1.11", "numba>=0.59", "tqdm>=4"]
15
+ keywords = [
16
+ "direction of arrival",
17
+ "passive sonar",
18
+ "source detection",
19
+ "Bayesian inference",
20
+ "reversible jump MCMC",
21
+ "sequential Monte Carlo",
22
+ ]
23
+ classifiers = [
24
+ "Development Status :: 3 - Alpha",
25
+ "Intended Audience :: Science/Research",
26
+ "Operating System :: OS Independent",
27
+ "Programming Language :: Python :: 3 :: Only",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Programming Language :: Python :: 3.14",
33
+ "Topic :: Scientific/Engineering",
34
+ ]
35
+
36
+ [project.urls]
37
+ Repository = "https://github.com/fincb/rjdoa"
38
+ "Bug Tracker" = "https://github.com/fincb/rjdoa/issues"
39
+
40
+ [project.optional-dependencies]
41
+ plot = ["matplotlib>=3.7"]
42
+ scripts = ["matplotlib>=3.7", "h5py>=3"]
43
+ test = ["pytest>=7", "h5py>=3"]
44
+ dev = ["rjdoa[test,scripts]", "ruff", "build", "twine"]
45
+
46
+ [tool.setuptools.dynamic]
47
+ version = { attr = "rjdoa.__version__" }
48
+
49
+ [tool.setuptools.packages.find]
50
+ include = ["rjdoa*"]
51
+
52
+ [tool.pytest.ini_options]
53
+ testpaths = ["tests"]
54
+ markers = ["slow: long-running statistical tests (deselect with -m 'not slow')"]
55
+
56
+ [tool.ruff]
57
+ line-length = 120
58
+
59
+ [tool.ruff.lint]
60
+ # Explicit, so the checks do not change with ruff's default rule set (which grew in 0.17).
61
+ select = ["E4", "E7", "E9", "F", "D"]
62
+
63
+ [tool.ruff.lint.pydocstyle]
64
+ convention = "numpy"
65
+
66
+ [tool.pyright]
67
+ extraPaths = ["tests"]
68
+
69
+ [tool.ruff.lint.per-file-ignores]
70
+ "tests/**" = ["D"]
71
+ "scripts/**" = ["D"]
@@ -0,0 +1,22 @@
1
+ """Bayesian wideband DoA estimation and detection with reversible-jump samplers.
2
+
3
+ :func:`estimate` is the one-call entry point: array data in, number of sources and
4
+ bearings out.
5
+
6
+ Subpackages
7
+ -----------
8
+ reversible_jump
9
+ Model-agnostic RJMCMC, nRJMCMC and RJSMC samplers.
10
+ doa
11
+ Wideband DoA model, array geometries, inference kernels, relabelling and plotting.
12
+ mixture
13
+ Richardson-Green Gaussian mixture used to reproduce the RJSMC paper.
14
+ dists
15
+ Fast scalar log-densities with Distributions.jl parametrisations.
16
+ """
17
+
18
+ from . import dists, reversible_jump
19
+ from .doa.estimate import DoAEstimate, estimate
20
+
21
+ __all__ = ["DoAEstimate", "dists", "estimate", "reversible_jump"]
22
+ __version__ = "0.2.0"