Trilateration as Simulation-Based Inference: Learning Position Posteriors When Walls Couple the Ranging Errors

Trilateration finds a device's position by measuring its distance to several fixed radio anchors and intersecting the resulting circles or spheres. Indoors this breaks down, because walls and furniture block the direct radio path. The measured distance then comes from a reflection: it is too long, sometimes wildly so, and its error distribution has two modes. The standard fix treats each anchor's error as an independent draw from a fixed mixture, for example "usually Gaussian, occasionally a positive bias." That assumption discards the most useful fact about indoor errors. Every anchor's bias comes from the same walls, and whether anchor 3 is blocked depends on where the device stands relative to the same partition that decides whether anchor 5 is blocked. The pattern of which ranges are inflated, and by how much, carries information about position. Writing down the likelihood of all ranges jointly means integrating over unknown wall materials, reflection paths and blockage events. No one can do that integral in closed form.

That is exactly the setting of likelihood-free inference, also called simulation-based inference. Here one can simulate data from parameters but cannot evaluate the probability of the data. The approach is to run a simulator many times and train a neural network to output the posterior distribution over parameters given data. We propose to treat indoor ranging in this way. A cheap geometric ray-and-timestamp simulator of a known floor plan generates range sets. Its unknown wall properties are sampled rather than fixed, and the anchor set has variable size. A permutation-invariant network trained on these simulations outputs, in one forward pass, a calibrated and possibly multimodal posterior over the device's coordinates. The central claim is testable. Most of the gain over robust trilateration comes from modeling the cross-anchor coupling of errors through shared, unknown geometry. We will show this by comparing against the same learned estimator constrained to factorize across anchors.

Core Claim

Let $\theta$ be the device position, $\eta$ the unknown environment parameters (wall permittivity and conductivity, small offsets of wall positions, clock parameters), and $r = \{(a_k, r_k)\}_{k=1}^{K}$ the observed set of anchor locations $a_k$ and measured ranges $r_k$. Standard robust trilateration uses the factorized likelihood

$$ p_{\text{fact}}(r \mid \theta) = \prod_{k=1}^{K} p(r_k \mid \theta, a_k), $$

where each factor is a per-anchor error model. The true likelihood is instead

$$ p(r \mid \theta) = \int \prod_{k=1}^{K} p(r_k \mid \theta, a_k, \eta, z_k)\, p(z \mid \theta, \eta)\, p(\eta)\, dz\, d\eta, $$

where $z$ collects the multipath events (which paths exist, which are blocked). Two things couple the anchors: the latent $z$, which depends jointly on $\theta$ and the shared walls, and the shared nuisance $\eta$. The second equation does not factorize.

The file supplies a statistical warning about this. Improving the Accuracy of Marginal Approximations in Likelihood-Free Inference via Localization shows that inferring from subsets of summary statistics while ignoring a nuisance parameter that controls their variance produces diffuse, biased or spurious-mode posteriors. Per-anchor processing in trilateration is the spatial analogue of that failure. Our proposal is to learn $p(\theta, \eta \mid r)$ jointly from simulations. We then show two things: the joint estimator beats the factorized one precisely in cluttered, anchor-poor configurations, and it stays calibrated when the real room differs from the simulated one.

Relation to Prior Work

The closest work falls into three groups.

The first group supplies the physical motivation. RayLoc inverts a fully differentiable ray tracer by gradient descent on position. To escape local minima created by ray hit-or-miss boundaries, it needs Gaussian smoothing of the loss, and it returns a single point. We share its view that multipath is signal, not noise. We differ in three ways: our estimator is amortized, we do not require a differentiable simulator, and we return a posterior. A Digital Twinning Platform for Integrated Sensing, Communications and Robotics precomputes commercial ray-traced delay profiles on a 5 cm grid and does nearest-neighbour matching. It reports a maximum error of about 16 cm with a twin whose geometric modeling error is under 8 cm. That work shows a simulator can be good enough to localize with. It infers neither environment parameters nor uncertainty. Precise Ranging models the bias and variance of ultra-wideband (UWB) double-sided two-way ranging and its time-difference variant under multipath. It reports a median variance-prediction $R^2$ of 77%, a 1.3 cm average bias-prediction error, and a five-fold variance increase for the passive time-difference mode. We reuse its per-link timestamp error model inside our simulator, so it plays a methods-supplying role.

The second group supplies the inference machinery. Automatic Posterior Transformation trains conditional density estimators directly on the posterior and allows sequential, proposal-based rounds. BayesFlow 2.0 provides amortized estimators with set-based summary networks and simulation-based calibration checks. On Lotka–Volterra it reports calibration error of 0.03–0.04 and posterior contraction of 0.92–0.94. BayesSim is the closest precedent for using likelihood-free inference to infer simulator physics parameters from real robot data, but it works on rigid-body dynamics with hand-crafted summaries. We carry over the joint inference of environment parameters to radio propagation, and we replace hand summaries with a learned set encoder. Amortized Simulation-Based Inference in Generalized Bayes documents overconfidence of neural posteriors under misspecification. We use its generalized-Bayes estimator as the misspecification-robust variant.

The third group provides the discriminative competition. Attending to Routers learns set-invariant attention weights that down-weight corrupted routers. It reports a 28.7% median-error reduction on the DLoc benchmark. That is strong evidence that anchor-wise reliability varies and is learnable. However, it is trained on real labeled surveys, and its output heatmap is not a calibrated posterior. We keep the attention-over-anchors architecture but train it on simulations with a density-estimation objective.

Research Program

We will build a fast, deliberately non-differentiable 2D/2.5D image-source simulator for a known floor plan. For a sampled position $\theta$ and environment $\eta$, it enumerates direct and first- and second-order reflected paths to each anchor and decides blockage from wall intersections. It attenuates each path by sampled material parameters and passes the resulting channel through the timestamp-level ranging error model of Precise Ranging. The output is a range, plus optionally a first-path power estimate. Anchors whose signal falls below a sensitivity threshold are dropped, so $K$ varies. The target cost is well under a millisecond per sample, which makes $10^6$ training simulations cheap. This addresses the simulation-cost problem that would make full electromagnetic solvers impractical.

The estimator encodes each anchor tuple (anchor position, range, optional power) with a shared network. It pools with self-attention in the style of Attending to Routers, and conditions a flow-matching or normalizing-flow density over $(\theta, \eta)$, implemented in BayesFlow 2.0. The floor plan is fixed per deployment. A second variant also conditions on a rasterized floor plan so that it can generalize across rooms. To guard against the sim-to-real gap, the environment prior $p(\eta)$ is deliberately broad. We also train a generalized-Bayes variant following Amortized Simulation-Based Inference in Generalized Bayes. We additionally test a two-stage refinement inspired by Drovandi et al.: after the first real observations, the posterior over $\eta$ from a short calibration walk becomes the prior for subsequent localization. This is the BayesSim idea applied to walls rather than friction.

Analysis will ask where the coupling helps. The quantities of interest are the number of visible anchors, the fraction that are non-line-of-sight, and the geometric conditioning of the anchors. Nearly collinear anchors inflate position error through geometric dilution of precision, and they are where multimodal posteriors should appear.

Baselines

The naive reference point is linearized least-squares lateration on the raw ranges, together with the closed-form sphere-intersection solver of A 3D node localization scheme for wireless sensor networks. That paper reports roughly one-third the CPU cost of lateration and accuracy that degrades once range noise exceeds about 5%. We also include the pairwise-circle-centroid method of Position Estimation of Robotic Mobile Nodes in Wireless Testbed using GENI, whose reported errors range from 0.65 m to 5 m depending on obstructions. These cost nothing to run and define the floor.

The strongest classical competitor is robust Bayesian trilateration with a hand-built per-anchor mixture likelihood: a Gaussian line-of-sight component plus a positive-bias non-line-of-sight component whose parameters are fit on the same simulated data. We sample it with MCMC, or with a particle filter for tracks. This is the method a signal-processing reviewer would reach for. It already yields posteriors and handles bias, so it is the fair test of whether learned coupling adds anything. Its mixture parameters get the same simulation budget as our estimator.

The key ablation is a learned factorized model. Neural likelihood estimation in the style of Sequential Neural Likelihood learns a single-anchor density $\hat p(r_k \mid \theta, a_k)$ from the same simulator with $\eta$ marginalized. The product over anchors then goes into MCMC. This model has the same simulator, the same flexibility per anchor and the same compute, but no cross-anchor coupling. Beating it isolates the proposal's central ingredient. A second ablation trains our joint estimator with $\eta$ fixed at nominal values, which isolates the value of marginalizing environment uncertainty.

The strongest discriminative competitor is the attention network of Attending to Routers, trained in two ways. The first uses our simulations with a heteroscedastic Gaussian or mixture-density head. The second, where labeled real data exist, uses real surveys. It gets the same architecture budget and hyperparameter search as ours. For the physics-inversion competitor, we run RayLoc-style multi-start gradient descent against a differentiable version of our own simulator, which is possible because our simulator's path set can be relaxed. The numbers reported in the file for the strongest methods are all relative or setting-specific. RayLoc reports reductions of 0.72–1.17 m in line-of-sight localization error over Widar2.0 and SpotFi. Attending to Routers reports a 28.7% median-error reduction and up to 39.4% at the 99th percentile on DLoc versus its baseline. The digital twin reports a roughly 16 cm maximum error in its lab. No reported absolute median error for DLoc was found on Lacuna, so we will re-run the attention model ourselves.

Beating the baselines means two things. First, a statistically significant reduction in median and 90th-percentile error relative to the mixture-likelihood and factorized baselines in the non-line-of-sight-heavy configurations, with no loss in open ones. Second, empirical coverage of 90% credible regions within a few points of nominal on real data, where we expect the factorized and fixed-environment variants to be overconfident.

Why not just…?

Why not just use robust trilateration with a per-anchor NLOS mixture likelihood? This is the real threat. If indoor biases were close to independent across anchors given position, this baseline would match us at a fraction of the complexity. Our hypothesis is that they are not independent, because blockage by one partition affects several anchors at once. The learned factorized ablation settles the question cleanly. It uses the same simulator but removes only the coupling. If the joint estimator does not beat it by a meaningful margin on real data in cluttered layouts, the coupling claim is false. We would then report that the value of simulation-based inference here is limited to better single-anchor error models.

Why not just train a supervised regressor, such as the attention network, on the simulated data? A mixture-density attention network trained on simulations is itself a crude posterior estimator, so the question is really whether a flexible density and joint environment inference matter. Evidence from Attending to Routers shows that such networks localize well but provides no calibration. The generalized-Bayes paper warns that neural posteriors become overconfident under misspecification. We will compare coverage and the frequency of bimodal posteriors directly. If the Gaussian-head regressor is equally accurate and equally calibrated, we will say so.

Why not just invert the simulator by gradient descent, as RayLoc does? RayLoc itself reports that ray-tracing losses have local minima that require Gaussian smoothing. It also needs a differentiable engine and online optimization per query, and it returns only a point estimate. Our multi-start baseline measures accuracy and wall-clock latency per query. When anchors are nearly collinear and two positions are equally consistent with the data, a point estimate must pick one. We will count how often it picks wrong in cases where our posterior places mass on both modes.

Why not just precompute a fingerprint grid from the digital twin? The digital twin platform reaches about 16 cm in a carefully modeled lab. However, its grid is tied to fixed wall properties, and storage grows with volume and resolution. We will build a grid from our simulator at nominal $\eta$ and perturb the real environment by moving furniture and adding occluders. We expect the grid to degrade, and our marginalized estimator to widen its credible regions rather than fail silently.

Proposed Experiments

In simulation, we first validate calibration with simulation-based calibration checks on held-out simulations across varied floor plans. We then measure the accuracy gap between the joint and factorized estimators as a function of the fraction of non-line-of-sight anchors and the anchor-geometry conditioning. This is a synthetic benchmark where the true posterior can be checked against rejection sampling for small $K$.

For real UWB data, we use the CLOVES testbed from Precise Ranging, with seven UWB transceivers under line-of-sight and multipath conditions. We supplement it with our own recordings: a mobile robot carries a UWB tag through two rooms with measured floor plans and camera ground truth, in the manner of the ACES and WLAN testbeds. Recordings cover both the two-way ranging mode and the passive time-difference mode, because the latter's five-fold variance increase is a stress test.

For Wi-Fi, we adapt the simulator to emit angle-of-arrival and time-of-flight features and test transfer on the DLoc benchmark used by Attending to Routers. That network, trained on real labels, is an upper reference for our simulation-only estimator.

Metrics are median and 90th-percentile position error, empirical coverage of 50% and 90% credible regions, negative log posterior density at the true position, and inference latency.

The decisive checks are three. First, the joint estimator must beat the learned factorized ablation on real cluttered data. Second, coverage must stay near nominal after controlled environment perturbations, while the fixed-environment ablation's coverage collapses. Third, a short calibration walk must sharpen the posterior over wall parameters and measurably reduce subsequent position error. If the first check fails, the paper's central claim fails with it.