dstl / Stone-Soup

A software project to provide the target tracking community with a framework for the development and testing of tracking algorithms.
https://stonesoup.rtfd.io
MIT License
384 stars 126 forks source link

Plotting Update #887

Open Carlson-J opened 8 months ago

Carlson-J commented 8 months ago
jmbarr commented 6 months ago

I'm not in favour of adding 'measurement uncertainty'. I think it conflates measurement -- a realisation of a sensing action -- with measurement model uncertainty. A single measurement is a sample drawn from a distribution defined by the measurement model. There's no uncertainty -- that's what the sample was. If you want to visualise how likely other samples are to appear in that vicinity you have to know what the likelihood of that sample was, which means you need the ground truth.

And we're plotting in state space. There isn't necessarily a linear relationship between state and measurement space which makes the ellipse you're trying to plot non-elliptical.

Carlson-J commented 6 months ago

I'm not in favour of adding 'measurement uncertainty'. I think it conflates measurement -- a realisation of a sensing action -- with measurement model uncertainty. A single measurement is a sample drawn from a distribution defined by the measurement model. There's no uncertainty -- that's what the sample was. If you want to visualise how likely other samples are to appear in that vicinity you have to know what the likelihood of that sample was, which means you need the ground truth.

@jmbarr I think the piece you are missing is that sometimes the uncertainty of a sensor is not constant. In real sensors, one can update the uncertainty based on the measurement. For example, given the SNR of a signal one can derive and update the uncertainty.

jmbarr commented 6 months ago

@jmbarr I think the piece you are missing is that sometimes the uncertainty of a sensor is not constant.

No, I understand this perfectly well. Stone Soup, with its ability to attach specific models to measurements, handles this quite well. The issue with plotting is that error bars (ellipses, etc) about a particular measurement do not accurately reflect the likelihood that this measurement was realised. Consider a low-likelihood realisation of a measurement, i.e. one from the edge of the sensor model distribution. Drawing a symmetrical error bound corresponding to the sensor uncertainty about this point would be incorrect. You are effectively saying that measurements from even lower-likelihood regions of the distribution are as likely as those from higher-likelihood regions. (This is easier to see with a diagram.)

Carlson-J commented 6 months ago

@jmbarr I see your point. The use case I am trying to address here is that I have some real radar data with uncertainty for each measurement. I would like to visualize how the tracker associates with and updates its internal uncertainty based on these measurements. Plotting the measurement uncertainty seems like the best way to visualize this. How would recommend displaying this information?

jmbarr commented 6 months ago

@Carlson-J it's a good question to which no wholly satisfactory (to my mind) answer exists. Assuming the uncertainty is intrinsic to the sensor (i.e. in no way a statistical representation of the a datum made by, say, repeated individual measurements), then the 'correct' thing to do is transform the ground truth into measurement space and represent uncertainty about that point -- that's where the object really is in measurement space.

Of course you can't do that with real data. As a compromise it might be instructive to plot the predicted measurement mean with the uncertainty about that. It's not strictly speaking the correct place to put the uncertainty but it would allow you to visualise the (potentially evolving) measurement uncertainty.

Carlson-J commented 6 months ago

As a compromise it might be instructive to plot the predicted measurement mean with the uncertainty about that. It's not strictly speaking the correct place to put the uncertainty but it would allow you to visualise the (potentially evolving) measurement uncertainty.

@jmbarr How is this different than what I have implemented? Given a datum and its uncertainty, we are plotting the point and its uncertainty in measurement space, which we can optionally transform into XYZ.

jmbarr commented 6 months ago

@jmbarr How is this different than what I have implemented? Given a datum and its uncertainty, we are plotting the point and its uncertainty in measurement space, which we can optionally transform into XYZ.

The difference is that you're plotting the mean of the measurement prediction, not the measurement itself. Whilst not a reflection of where the measurement is likely to occur (which requires the ground truth), it's at least a reflection of where you think the measurement is likely to occur. And, crucially, allows you to visualise the sensor uncertainty.

Carlson-J commented 6 months ago

@jmbarr When I plot it I am plotting the actual measurement, i.e., I don't add any noise to it. I do not see another way to plot actual data in the current famework. Is there a way to plot the actual measurement in a way that is more aligned with your liking?

jmbarr commented 6 months ago

@jmbarr When I plot it I am plotting the actual measurement, i.e., I don't add any noise to it. I do not see another way to plot actual data in the current famework. Is there a way to plot the actual measurement in a way that is more aligned with your liking?

I think you plot the measurement via plot_measurement. You can't plot a prediction+uncertainty this way so perhaps use plot_tracks with a new keyword? (You can get the Prediction out of the Update but you might have to recalculate the predicted measurement.)