There has been recent global interest in the use of Bluetooth Low Energy (BLE) Received Signal Strength Indicator (RSSI) as a proximity sensor. This is motivated by the international Covid-19 pandemic and the use of mobile phone applications to help control infection propagation through the population. At the time of writing, many of these applications are using Bluetooth Low Energy (BLE) to infer whether people are close together for prolonged periods of time, since proximate, prolonged exposure to an infected person correlates with the probability of infection [8, 27] .
Unfortunately, BLE RSSI is a very noisy sensor of proximity. Due to the usual vagaries of radio frequency propagation in general environments, e.g. multipath, reflection, shadowing and fading, it becomes challenging to infer proximity from observed values without taking into account uncertainties in the data generating process.
To illustrate the highly variable behaviour of RSSI values, consider the plots in Figure 1 . These all show RSSI values recorded at a fixed distance (1m for the Trinity College data sets, and 6ft for the MIT data sets) over time. Notice the extreme shifts and large variances; these are due to a multitude of sources, e.g. device type, orientation, position on body and the person's local environment.
There have been various attempts to work with RSSI in a principled manner in Covid-19 mobile applications. In the popular Exposure Notification system [1, 3] used by Google and Apple devices, RSSI is "discretised" into buckets, and bucket thresholds are set by application developers. The documentation [2] reasons that RSSI is useful for inferring close proximity, but not at all effective for inferring larger distances.
(a) Trinity College Dublin data, from [16] .
(b) MIT PACT data [15] . Figure 1 : Samples of RSSI data over time from two sources. The Trinity College data here are all recorded at a proximity of 1m, and the MIT data at 6ft. All plots across both sources share the same y-axes [−100, −50].
In this paper, we present a probabilistic model for inferring proximity using BLE RSSI observations. This model uses a Unscented Kalman Smoother (UKS) [11, 12] , which takes advantage of sequential RSSI data, and models multiple sources of uncertainty in the data distribution variance. For the data distribution, we use a Gaussian process that maps distance to observations, and present two general forms: a generative model, which directly models the sources of shifts and variance in the observations; and a discriminative model, which learns a suitable observation model from training data. Setting this paper's contribution in context, the estimation of a distribution over proximity is just one technical problem that needs to be addressed; the reader is also referred to [22] for a broader discussion around the ethical considerations around contact tracing app development.
Since the Covid-19 outbreak, there has been a surge of interest in proximity inference using BLE RSSI data. Since risk of infection is a function of, iter alia, proximity between individuals and the duration of contact [8, 4] , automatically inferring these two properties for any contact "event" is crucial.
Perhaps the most notable work exploring the effects of BLE RSSI in real-world environments, and its potential as a sensor of proximity, are the series of papers by Trinity College Dublin. For example, in [16] , the authors demonstrate the extreme shifts and variation in RSSI over a variety of contexts, including on public transport, in supermarkets, walking in public streets and sitting at desks. There are also scenarios demonstrating the shifts in RSSI from simply putting a mobile device in a pocket or a bag. The data in Figure 1 are taken from this paper.
In [17] , the authors show that in this public transport environment with 60 device pairs, the Exposure Notification system with particular parameter settings did not detect genuine contact events, though minor improvements were made through parameter variation. Further evidence of the difficulties of using RSSI is illustrated in [18] , with the best performing parameter settings achieving the equivalent of random selection.
Other recent studies into Bluetooth for proximity detection include: [19] , where further tests of Bluetooth in indoor and outdoor environments, as well as device concealment variations, show the volatility of RSSI and the ambiguity at larger distances; and [21] , where BLE is used for proximity detection in the workplace, albeit with exposed bracelets and additional environment sensors, and good binary classification of contact events is achieved through varying scan windows at a cost of power consumption (the drop in performance for low-power, lower frequency methods even in a "good coverage" environment is noted).
Methods that make use of RSSI sequences include [25] , which uses particle filtering on Bluetooth RSSI to infer proximity in idealised environments. The findings are unlikely to translate to everyday mobile phone use however, since they were obtained from sensor networks with different Bluetooth hardware, where the setup was designed specifically for object tracking. Other methods have used Kalman filters, which assume linear transforms for state transition and observation. In [28] , a Kalman filter was applied to the indoor location estimation problem but, again, the hardware and experiment setup used (highpower class 1 Bluetooth sensor networks set up for tracking) do not translate to real-world mobile device use. Similar studies used augmented sensors, e.g. an inertial sensor [30] , in environments designed for tracking, e.g. [31] and some have considered particle filters with Gaussian processes for sequential modelling [10] .
In direct response to the Covid-19 crisis, other approaches to proximity detection with realistic context and BLE hardware have been studied. These include Gorce, Egan and Gribonval [9] , who use calibrated BLE RSSI, where shifts due to device type, position and environment are considered, as well as probabilistic modelling of fading and shadowing. The authors then use Bayesian inference to compute a posterior distribution over distance given (averaged, calibrated) RSSI observations. This posterior uses a constrained uniform prior with Gaussian data distribution over the RSSI observations. Different estimators are derived from this posterior, such as the maximum a posteriori and maximum likelihood distance. These are then used in various risk scoring approaches, and experiments show reasonable risk inference using this method. This work is similar to ours in its Bayesian approach, though it does not take sequences into account. Moreover, we model shifts as random variables in the data distribution rather than through correction and averaging.
Given a sequence of observed RSSI random variables R 1 , . . . , R T , we wish to compute the probability distribution over device proximity, or distance, at each observation, i.e. D 1 , . . . , D T . Since RSSI data are likely to be aperiodic, bursty and unreliable, we might wish to treat D 1 , . . . , D T as a subsequence of a larger, periodic sequence D 1 , . . . , D T , where T ≤ T and also infer the proximity at points where observations are not present (see Section 3.1.1). Since (negative) RSSI appears to have a longer tail to ∞ in empirical data, e.g. Figure 1 and the plots in [9] , and that BLE typically has transmission power ≤ 0dBm, we model −R as a log-normal random variable. This is in contrast to popular radio propagation models such as the log-distance path model, which assumes the variability in R follows a Gaussian distribution. For completeness, we have replicated all results in this paper under the assumption of R being a Gaussian random variable (see Appendix C), and the log-normal model appears to be more resilient to fluctuations in RSSI, as discussed in Section 8.
Under this log-normal model, we are interested in modelling the data distribution of the Gaussian random variable X = log(−R) ∈ R conditioned on a distance (or proximity) variable D ∈ (0, ∞), where R ∈ (−∞, 0) is RSSI in dBm at distance d 1 . We assume this conditional distribution is characterised by a collection of D-dependent parameters Θ(D),
and, given this data distribution for X | D along with the sequence of observations X 1 , . . . , X T , our goal is to infer the posterior distribution over D t at each time index t ∈ {1, . . . , T } F Dt|X1,...,X T (D t | X 1 , . . . , X T , Θ(D t )) .
We further assume that this distribution (and the data distribution) admits a density with respect to Lebesgue measure, and we compute
This is a classic problem in dynamical systems' theory, and is well suited to methods such as Kalman filtering, smoothing and other derivatives. The choice of method depends on the form of the data distribution, and performance depends heavily on the quality of the data distribution, i.e. how closely it matches nature's "true" distribution.
The Kalman filter and smoother are classic methods for performing posterior inference over latent variables x 1 , . . . , x T ∈ R m given discrete sequences of observed vectors in z 1 , . . . , z T ∈ R n . The traditional Kalman smoother assumes that the latent sequence has the Markov property, all transforms are linear and that all stochastic sources are Gaussian. The state transition model, assuming no control inputs, is
where w t ∼ N (0, Q t ). The observation model is 1 We assume BLE transmission power is always < 0dBm
Unfortunately, in our application of inferring proximity from BLE RSSI, the observation model is non-linear and the latent variables D only have non-negative support. We can work around the latter problem by assuming D t ∈ R and transforming D t to its absolute value, i.e. |D t | -this implicitly assumes that the transition distribution is folded normal, rather than normal. The nonlinearity of the observation model leads us to use an extension to the traditional Kalman smoother: the Unscented Kalman Smoother (UKS) [11, 29, 5] . The UKS uses deterministic inspired sampling to allow nonlinear transforms in the model. Our transition model for the UKS is
where w t ∼ N (0, q t ). This model is equivalent to assuming that the two devices are each performing an independent Gaussian random walk, and that the relative proximity transition follows a folded normal distribution. The key parameter in this model is q, the variance of the change in proximity between time steps. The observation model is
where v t ∼ N (0, r t ). In other words, X t ∼ N (µ (D t ) , r t ).
One of the key advantages of the UKS, and dynamical systems in general, is the ability to infer the posterior distribution over D t , even when an observation X t does not exist. This is well suited to RSSI data, which are bursty, aperiodic and unreliable. This illustrates another benefit of posterior inference over sequences of observations, rather than single observations independently. Other approaches use averaging to smooth observations and inferred values over time windows, e.g. [9] , but the sequential nature of the UKS allows for more principled imputation, where observations either side of a "gap" induce a more realistic trend in the inferred values.
Assuming the data distribution
is Gaussian, i.e. X | D ∼ N (µ (D; θ µ ) , r (D; θ r )) ,
with {θ µ , θ r } ∈ Θ(D) then, for distances d,
is a Gaussian process and, for any given d, the Gaussian for X d depends entirely on the hyperparameters Θ(D). Thus, we can encode knowledge of the distribution of X at certain distances in our choices for the hyperparameters. If we have access to appropriate training data, we can use these data to learn Θ(D) for RSSI behaviour in general environments. There are two main approaches for doing this: a discriminative approach, which learns representative parameters from training data; and a generative approach, which models directly the sources of RSSI variability. We consider both approaches and assess their performance in subsequent sections.
In this section, we outline a model for the Gaussian data distribution
Unfortunately, the vagaries of radio frequency propagation within different environments make physical modelling of this distribution very difficult. Empirical data, e.g. [6, 9, 15, 16] suggest that the distribution of R in a "clean" environment, e.g. an anechoic chamber, has a unimodal, asymmetric form, with a long tail towards −∞. We assume that the distribution of X is unimodal and symmetric about the mode, and a member of the location-scale family of distributions.
For a given distance D = d, we assume the existence of a fixed function f : (0, ∞) → R, which captures the physics of radio propagation in free space as a function of distance. We use a simple RSSI propagation model, which approximates line-of-sight received power in free space using the Friis transmission equation,
where P r is received power (in W); P t is transmitted power; G t and G r are transmitter and receiver gains respectively; d is distance between transmitter and receiver (in m); and λ is wavelength (in m). We use the decibel conversion
where λ = 0.125 is Bluetooth wavelength in metres 2 . We assume the transmitted power to be 0dBm, and that antenna gains for the transmitter and receiver are captured in the shift variables below. The base function f (d) is then f (g(d)) = log(−g).
In our model, this function can be shifted by a finite number N s of independent random variables Y i | d -which may represent, e.g. antenna orientations, device model differences and changes in the physical environment -plus some zero-mean unattributable, independent, distance-invariant noise Z. With these forms and assumptions, we have, given D = d
and,
with
In this section, we outline a generative model for certain shift variables Y i and noise variable Z, each of which we assume to have Gaussian mixture form with K i components at distance d,
and -in general -unknown d-specific π k , µ k and σ 2 k . For each variable Y i , we assume we have access to some empirical observation data for each component k: D k (which could be empty, i.e. D k = ∅). We place a conjugate normal-inverse-gamma prior over each Gaussian component's parameters µ k , σ 2 k to obtain the posterior distribution,
and a conjugate Dirichlet prior over the mixture components, to obtain the posterior
and marginalise over the unknown parameters in Equation 10 to obtain the posterior predictive distribution
where each component has the form
i.e. each component is t ν (· | µ, σ): a non-standard Student's t-distribution with ν degrees of freedom. Thus our concrete distribution for Y i | d is an average mixture of Student's t-distributions. Using standard results from conjugacy and
and, for the mixture components, given any multinomial observations of component frequencies
For the unattributable noise Z, we assume zero-mean Gaussian with unknown variance σ 2 Z . With zeromean and a single Gaussian component, the derivation of the previous section shows that
and we require α > 1.
We focus on three classes of Y : device type shifts caused by differences in mobile device hardware; shifts caused by antenna gain variations; and context shifts caused by device usage, e.g. position, location and environment.
• Device type: different device types affect shifts and variance of X [9] , so this is one example of a shift variable Y . It also appears that this shift is different for different sender/receiver pairs. Given N device types, i.e. specific makes and models, we have K = N 2 sender-receiver pairs. Following
Given choices for prior hyperparameters θ k , we can collect data on sender/receiver device shifts by measuring them empirically, e.g. in an anechoic chamber, and updating the posterior hyperparameters. We can also use mobile device market share data or survey data to update the Dirichlet parameter in Equation 14 .
• Antenna gain: the Friis transmission equation in Equation 6 usually includes terms for losses in received power due to directivity of the transmitter and receiver. We encode these losses in a random shift variable Y , with a single component. Thus Equation 11 becomes
(1 + λ)β λα 1 2 , and empirical data on directivity shifts can be use to update the posterior parameters.
• Device position, location and environment: other sources of variability for X include device (antenna) position, e.g. orientation; device location, e.g. in pocket; and environment, e.g. indoors.
Since these are typically not independent, the shift Y depends on the joint distribution of the variables P (position), L (location) and E (environment). If we assume the position, location and orientation variables take values in finite sets, then our mixture model will have K = N P ×N L ×N E components and we have the form of the posterior predictive mixture of Student's t-distributions in Equation 11 . Again, we can use empirical data for each component D k to update the posterior hyperparameters.
The purpose of a discriminative model is to learn suitable parameters Θ(D) from training data. This learning process is an optimisation problem, and we wish to find suitable parameters that maximise a particular objective function.
There are a range of parametric forms that we could use for the discriminative model of the data distribution in Equation 5 . We consider two here: the first is a scaled and shifted base function f (d) with d-invariant scale and shift parameters θ µ1 and θ µ2 respectively, i.e.
and the second disregards the base function f and assumes a logarithmic form with d-invariant scale and intercept, i.e.
For both forms, we also have the observation variance θ r and transition variance q for the UKS. The parameters for optimisation are therefore Θ(D) = {θ µ1 , θ µ2 , θ r , q}.
The first objective function is to minimise the expected average mean-squared error between true distances D 1 , . . . , D T and the expected value of the posterior distribution returned by the UKS inference process. That is, given N training data sets D 1 , . . . , D N , where -to account for missing observations -D n contains a periodic sequence of true distances (d 1 , . . . , d Tn ) and a generally aperiodic, subsequence of observations (x 1 , . . . , x T n ) with T n ≤ T n . We wish to find For the discriminative models, "prox." means proximity optimised using Equation 19 and "risk" means risk optimised using Equation 21.
The second objective function is to minimise the risk error. We use the risk score from [4] for one time step under the assumption of maximum infectiousness and minimum time decay as
where ∆t is the time step (in seconds) between periodic true distances, and search for parameters that minimise the expected average mean-squared risk error,
Unfortunately, the complexity of the UKS means that evaluating any objective function involves running a full smoothing process over each training data set D n . For the n th training set, this is O(T n ) (since we have single dimensional latent and observation spaces) and so, for N training sets, a single evaluation of an objective function is
Because of this, we use Bayesian optimisation [26] . Bayesian optimisation uses a Gaussian process as a surrogate function to optimise low-dimensional objective functions with high evaluation cost. Since we have at most 4 model parameters to optimise, our problem is well-suited to the Bayesian optimisation approach. The experimental setup and results for the discriminative models are detailed in Section 7.5.
In this section, we apply both model types to various data sets. We first outline the configuration for each type and the data sets involved in parameter learning, before detailing the test data sets and presenting performance results on each for all models.
As a benchmark for comparison, we trained a gradient boosted regressor on the MIT Matrix data set [7] . These are RSSI data captured in a variety of contexts at 8 different distances: 3, 4, 5, 6, 8, 10, 12 and 15ft. There are 107 files consisting of 118 individual pairwise interactions.
For training, we merged all RSSI points into one set, and used 3-fold cross validation with a test proportion of 0.33. For the gradient boosting, we used LightGBM [13] with Root Mean-Squared Error (RMSE) loss function on distance, 31 leaves and 100 iterations. The learned prediction function is shown in Figure 2 (b).
For discriminative model training data, we again used MIT's matrix data set [7] . We use 3-fold, stratified cross-validation on the data sets to choose the optimisation parameters for each model. The stratification is set so that at least one data set from each recorded proximity appears in both the training and validation sets. For each data set, we resample to ∆t = 1s (we take the mean for multiple observations in a single time step).
For these results, we use 100 rounds of Bayesian optimisation over the full UKS from 10 initialisation points using a Matérn kernel for the Gaussian process with ν = 5/2 and a small perturbation on the observed points (1 × 10 −6 ). 
We use the model in Equation 16 , with α set with counts of observations of UK mobile device market share data from 2019 [24] , i.e. from the survey of N = 2, 123 respondents,
where p r is the proportion of the N respondents with device type r, and p t the equivalent for type t, with K = r 2 = t 2 . This hyperparameter controls our belief in the specific device types in a randomly selected pair for the UK.
GSMA have provided us with calibration offset data in dBm for 27 device makes and models. These are single observations of shifts at d = 1m for certain transmitter/receiver device pairs in an anechoic chamber. We therefore do not have empirical data sets for our posterior predictive model in Equation 16 , so we assume these figures set the µ 0 hyperparameter for pair k, and that they were recorded with some uncertainty (encoded in the choices for λ 0 , α 0 , β 0 ). Since the figures are reported in dBm, we convert these to X space as follows. . Hyperparameters were set using anechoic chamber data for 729 (27 2 ) device pairs. α was set using UK mobile device market share data (see text). Right: 1, 000 samples from p Yi|d (Y i | D 1 , . . . , D K , Θ) for assumed distance-invariant device position, location and environment shifts using HMC with NUTS. Hyperparameters were set using the MIT PACT data set [15] . α was set using survey data on mobile device usage (see text).
We view each supplied shift k as a d-invariant shift in the negative Friis transmission equation −g(d). So, for k > g(d) and g(d) < 0, this produces a corresponding shift δ k in f (d) as follows
and we see that a constant k results in a δ k that varies with d through g(d).
We can therefore define our device type shift variable Y i ∈ R, and assume that the supplied δ k is the µ 0 parameter in Equation 12 . λ 0 , α 0 and β 0 encode our uncertainty about Y i , and we set them to λ 0 = 1, α 0 = 2 and β 0 = 1/10 to give small variance about µ 0 . Samples from p Yi|d (Y i | Θ(d)) for d = 1m are shown in Figure 3 .
In addition to the calibration data supplied by GSMA, an estimated gain figure (in dBm) for the calibration reference device was also supplied. We follow the approach of the previous section to convert this to X space,
and set the d-specific hyperparameter µ 0 = δ. We again choose α 0 = 2, β 0 = 1/10 and λ 0 = 1.
We use the model in Equation 11 , with the following hyperparameter settings. We assume the environment factor is split into two: indoors and outdoors. We set the indoors' probability to p(E = indoors) = 0.869 and the outdoors' probability to the complement, which are taken from the National Human Activity Survey (NHAPS) [14] .
For device location, we use the data from [20] and assume a mobile device is not concealed for 8 hours (sleep) plus 3.25 hours in active use plus 8 hours not in use but nearby, e.g. working; leaving 4.75 hours with the device being concealed in a pocket or bag. Thus, we set the concealed probability to p(L = concealed) = 4.75/24, and the not concealed probability to the complement.
For device position, we assume equal belief to all orientation angles in a 2D plane. So, for any finite K-partitioning of [0, 2π) into intervals I 1 , . . . , I K , we set p(P ∈ I k ) = |I k |/2π. With these, the k th component of the Dirichlet hyperparameter becomes, for realisation (p, l, e) k ,
where N is a pseudocount, which we set to 10.
For the remaining posterior predictive hyperparameters, we use the PACT datasets provided by MIT [15] . These contain measurements for two "real world" environment classes (1 outdoor and 3 indoor, with the 3 indoor sets merged) over two transmit location classes (3 concealed and 1 in hand, with the 3 concealed sets merged) over 8 angles of orientation. We use these data to set the parameters in Equation 13 -with µ 0 = 0, λ 0 = β 0 = 1/10 and α 0 = 2 -as follows.
We use the reference data sets recorded over location (concealed and in-hand) and positions (8 angles) in an anechoic chamber. We assume these are observations of noisy reference RSSI, and fit a normal distribution to X := log(−R),
where the parameters are the sample mean and (unbiased) variance for each of the 16 reference sets. For the 32 other data sets, we observe shift variables as follows. For a given data set D p,l,e = x 1 , . . . , x N p,l,e , we drawx 1 , . . . ,x N e,l,p ∼ N (μ l,p ,σ 2 l,p ), and use the observed shifts y i = x i −x i . These data are then used to compute the parameters for the t-distributions using Equation 13 . See Figure 3 for samples from the full distribution of Y i using these posterior parameters, and the mixing weights' distribution parameters described above.
With the distributions of Y i | D 1 , . . . , D K , Θ and the value of Var (Z | θ Z ) set in the previous sections, we can approximate the expectation and variance of X with Equations 8 and 9. For this we use use HMC with NUTS to estimate the expectations in Equations 8 and 9. The resulting Gaussian process under the computed estimates is shown in Figure 2 (a). Figure 4 shows the UKS with generative observation model tracking proximity from noisy simulated data using RSSI generated from devices in the MIT H0H1 data set [6] .
For performance evaluation, we use the MIT H0H1 data set [6] and the Trinity College Dublin data sets from [16] .
This data set consists of RSSI captures from 26 "high risk" scenarios (H1), and 19 "low risk" scenarios (H0). We define a scenario to be an interaction between a device pair, and some of the raw data files contain multiple device interactions. There are iPhone and Android devices present in the data sets.
In the H1 scenario, participants were asked to stay within 6ft of each other for 15 minutes. In the H0 scenario, they were asked to stay at least 10ft apart for 15 min. In each scenario, participants were instructed to interact with each other normally in multiple environments, including: outdoors, indoors and sat at a table. Participants were also allowed to use their mobile phones as normal throughout the study.
We do not know if participants genuinely strayed over the instructed boundaries, nor do we know if each raw data file was intended to capture a single interaction. We include all mobile phone interactions in all files regardless.
Since we have proximity and risk bounds only, we cannot measure exact inference, but we know that the models should infer proximity ≤ 6ft for H1, and ≥ 10ft for H0, and thus "high risk" and "low risk" respectively.
This data set consists of RSSI readings in a number of settings, some of which are laboratory settings and some real-world settings. We use the real-world, or scenario settings, which consist of 14 sets of RSSI data in environments such as supermarkets, desks, public transport and walking in public. An approximate ground truth proximity is labelled for each set, though we do not know if participants 09 applied to simulated random walk data. Here, two iPhone XR devices undertake a random walk at on a circle with radius 2m for 1, 000 seconds. We fit a sampling model with iPhone XR device types known (that is, without the mixture component over device type) from the MIT H0H1 data sets [6] . This results in a Gaussian process with µ(d) = 0.21 log(d) + 3.92 and σ 2 = 0.33. RSSI samples are then generated at each time step from log-normal(µ(d), σ 2 ). In this example, half the observations are removed randomly to simulate imperfect sensor reliability. The topmost plot shows the RSSI data; the second plot shows the UKS with momentmatched gamma distribution 0.05 and 0.95 quantiles; the third and fourth plots show true and inferred risk coloration respectively -high risk, i.e. when within 1m of each other, is the thicker, solid red line; low risk is the thinner, dashed green line. Note the imputation of the UKS where there are missing observations. rigidly adhered to this proximity throughout the capture. There are only Google Pixel 2 devices present in the data sets. For the proximity plot, a good proximity classifier would put all points in the H1 column below the black x-y line, and all the points in the H0 column above the black x-y line. A good risk classifier would put all points in the H0 column above the red dashed line (the H1 threshold). Figure 6 shows example time series for the UKS with different models on an H1 and H0 scenario. Figure 7 shows inferred risk against true risk for the Trinity College Dublin scenarios in [16] , the figures from which correspond to the plot legend labels in Figure 7 . 
Here we discuss the implications and limitations of the results in the previous section. The key finding is that good prediction of proximity and risk can be achieved by treating RSSI sequences and using posterior inference of proximity D t given the entire sequence of observations x 1 , . . . , x T rather than x t alone. By using a UKS, we can undertake this inference with nonlinear observation models; in this case Gaussian processes, which also encode uncertainty that propagates through to the posterior distribution over D t . Given the single dimensions of both state space and observations, inference for a periodic sequence D 1 , . . . , D T can be achieved in linear time, i.e. O(T ). Using sequential modelling with Gaussian process data distributions outperforms simpler thresholding approaches such as the Exposure Notification API (cf. the effectively threshold-based gradient boosting AUC of 0.5 on MIT H0H1, which seems to corroborate the findings in [18] ). We next we compare the performance and suitability of proximity inference vs direct risk inference, before analysing the results of the generative and discriminative approaches. Next we acknowledge the implications of making a log-normal assumption for the distribution of −R, before discussing general limitations and potential areas for improvement in future work.
Our chief intention is to infer posterior proximity given observed RSSI values, but there is an argument that predicting infection risk directly is more pertinent, especially given the application to the Covid-19 pandemic. The plots for the MIT H0H1 data in Figure 5 and the Trinity College data in Figure 7 show how the duration component of risk can make some encounters significantly more important to classify correctly. This implies that jointly inferring proximity and duration is arguably more important than proximity alone since, for example, a long duration at a farther proximity can equate to a shorter duration at closer proximity, and a classifier that seeks to predict close encounters well at the cost of incorrectly predicting farther ones may not achieve the desired effect of good overall infection risk prediction. We have not inferred duration here beyond the time duration of the scenarios in the test data, but an area for further work would be to better improve duration inference from real world RSSI observations.
The results show that using the UKS with either a generative or discriminative model will likely outperform simple classification approaches, but there is a question as to which model is more appropriate. The generative model is the best performing approach for the MIT H0H1 data ( Figure 5 ), but the discriminative models outperform the generative model in the Trinity College data (Figure 7 ). There is an argument that the generative model is more general, since the discriminative models are limited by the training data, but the hyperparameters of the generative model are also computed from example data. There is arguably more flexibility to the generative model, since arbitrary numbers of shift variables Y i can be added, but there is no strong evidence in our results to recommend choosing one over the other. The question of which discriminative model to use is also not answered definitively, but the results in Figures 5 and 7 show marginally better performance using the form of Equation 17 over Equation 18 . There are also limitations introduced by the search restrictions of Bayesian optimisation, and there may be better parameters for these models that were not found in the optimisation process.
It is perhaps unsurprising that the scenarios with the greatest error are where the mobile device is in the pocket with the individual sitting ( Figure 5 ; false negatives), and where the device is in the hand ( Figure 5 ; false positives).
The main results in the paper assume that −R is a log-normal random variable, but there is a valid argument that R should be normally distributed, e.g. in the log-distance path loss model for radio propagation. Our justification for using the log-normal distribution was based on empirical evidence of a long tail in observed real-world RSSI values, plus the assumption that transmission power should be at most 0dBm for BLE in mobile devices.
We have replicated all results using a normally distributed R, i.e. X := R, and these can be seen in Appendix C. There is a small difference in performance, with the log-normal model performing slightly better in general on the test data sets. The notable exception is the generative model on the Trinity College data (Figure 7 vs Figure 13 ), but the average performance of the log-normal appears to be slightly better. We conjecture that this is due to the resilience against RSSI fluctuations due to the long tail of the log-normal data distribution (compare the steadiness of the inferred proximity in Figures 6  and 12 ).
Since we have not attempted to infer duration here, an obvious next step would be to focus on this; perhaps by attempting to partition RSSI data into sessions. We have also not considered other machine learning classifiers beyond a gradient boosting regressor, and it is entirely possible that a well-trained neural network could perform well, though we argue that much of the performance stems from the . The plot legend refers to figures in [16] . The n.c. and c. refer to "not corrected" and "corrected" respectively.
sequential modelling, and a sequential neural network may be a better choice. (These approaches are of course limited by access to good quality training data.) The other advantage of the UKS is uncertainty quantification, since we have posterior probability distributions over D t and can report our confidence in the inference given the many sources of uncertainty in the data and underlying dynamics.
Other potential improvements could include: acquiring more, high quality training data for the models; exploring more complex UKS approaches, though it may be prudent to keep state space dimensions low since inference is naïvely O(T d 3 ); optimising discriminative model parameters using approaches other than Bayesian optimisation; exploring data distribution forms other than log-normal (and Gaussian), e.g. the compound k distribution; and analysing performance as RSSI quality deteriorates, either due to noise or by intention for conservation of power.
The inference of proximity from BLE RSSI is a difficult problem, and more learning and validation data sets captured in varied scenarios (including from simulations) can only benefit any modelling approach.
In this paper, we presented a novel approach to inferring proximity from BLE RSSI using a UKS with Gaussian process data distribution. This is especially relevant to mobile phone applications designed to tackle the Covid-19 pandemic, which rely on good inference of infection risk; itself a function of proximity. We outlined two approaches to characterising the data distribution: a generative model, which directly computes sources of variability in observations; and a discriminative model, which optimises model parameters on example training data. There is no strong evidence to choose the generative approach over the discriminative one (or vice versa). Risk and proximity inference performance on two real-world data sets -MIT H0H1 and Trinity College Dublin -show that the UKS outperforms a more traditional gradient boosted regressor model. Our work to date offers an insight into well established mechanisms for probabilistic modelling of one of the key latent factors, that of proximity. We recognise that this needs to be considered in the wider context of health policy, ethical and other technical considerations, when responsibly deploying novel technology of this kind. For the discriminative models, "prox." means proximity optimised using Equation 19 and "risk" means risk optimised using Equation 21 .
There is some debate about a suitable distribution for X. In the paper, we assumed a log-normal distribution on raw RSSI R and used a log transform to define the normally distributed X := log(−R). This was motivated by asymmetric forms observed in empirical data, with long tails going to −∞ andunder the assumption of at most a 0dBm transmission power -support on (−∞, 0]. In this supplement, we replicate all the results in the paper under a direct Gaussian model on R, i.e., we define X := R. This shows that the log-normal model is more robust to noise, but that performance on the test data sets is comparable.
The base function f in Equation 7 is now equivalent to Equation 6, i.e. f (d) = g(d).
In this section, we present the model configurations and results under the direct Gaussian observation model.
For these results, we use 100 rounds of Bayesian optimisation over the full UKS from 10 initialisation points using a Matérn kernel for the Gaussian process with ν = 5/2 and a small perturbation on the observed points (1 × 10 −6 ). For the model in Equation 17 , we used the following search ranges: θ µ1 ∈ [1., 1 Hyperparameters were set using anechoic chamber data for 729 (27 2 ) device pairs. α was set using UK mobile device market share data (see text). Right: 1, 000 samples from p Yi|d (Y i | D 1 , . . . , D K , Θ) for assumed distance-invariant device position, location and environment shifts using HMC with NUTS. Hyperparameters were set using the MIT PACT data set [15] . α was set using survey data on mobile device usage (see text).
The δ k shifts in Equations 22 and 23 simply map directly to negative k , i.e.
The normal distribution in Equation 24 is fit to X := R rather than X := log(−R). The variance in Equation 15 is set to 10dB, i.e. β = 10, α = 2.
The ROC AUC for the approaches are: gradient boosting regressor: 0. True proximity, coloured by UKS risk Figure 10 : The UKS with generative observation model and q = .09 applied to simulated random walk data. Here, two iPhone XR devices undertake a random walk on a circle with radius 2m for 1, 000 seconds. We fit a sampling model with iPhone XR device types known (that is, without the mixture component over device type) from the MIT H0H1 data sets [6] . This results in a Gaussian process with µ(d) = −8.69 log(d) − 67.9 and σ 2 = 97.03. RSSI samples are then generated at each time step from N (µ(d), σ 2 ). In this example, half the observations are removed randomly to simulate imperfect sensor reliability. The topmost plot shows the RSSI data; the second plot shows the UKS with momentmatched gamma distribution 0.05 and 0.95 quantiles; the third and fourth plots show true and inferred risk respectively -high risk, i.e. when within 1m of each other, is the thicker, solid red line; low risk is the thinner, dashed green line. Note the imputation of the UKS where there are missing observations. pocket, standing pocket, sitting hands, held Figure 11 : Left: relative risk, i.e. inferred risk minus true risk (bound), for MIT H0H1. H1, H1 means the high-risk scenario with high-risk threshold. H0, H0 is the low-risk scenario with low-risk threshold. H0, H1 is the low-risk scenario with high-risk threshold. Right: inferred proximity against true proximity (bound) for MIT H0H1. The two columns of points (with jitter) are the true bounds for H1 and H0 respectively. The red dashed line is the H1 proximity bound. GBR is the gradient boosted regressor; UKS g. is the generative model; UKS f.r./f.p. are the discriminative models in Equation 17 optimised for risk/proximity. UKS l.r./l.p. are the equivalent for Equation 18 . See text for further details on plot interpretation. . The plot legend refers to figures in [16] . The n.c. and c. refer to "not corrected" and "corrected" respectively.