Stone-Soup icon indicating copy to clipboard operation
Stone-Soup copied to clipboard

Using a 1D measurement model noise covariance matrix doesn't produce an error message

Open gawebb-dstl opened this issue 2 years ago • 1 comments

I recently made a small mistake when creating the covariance matrix for a measurement model. I used: noise_covar=np.array([...]) which creates a 1D array instead of: noise_covar=np.diag([...]) which creates a 2D square array with values along the diagonal

Using the wrong covariance matrix doesn't produce any error messages. The detections are produced successfully with scipy.stats.multivariate_normal.rvs produces the same result with either input. However the measurement covariance matrix is used when tracking. It's used when calculating the innovation covariance. This doesn't produce an error message either but does give the wrong result. Which leads to really bad tracking.

To can observe this by changing line 130 in tutorial number 2.

Fortunately I spotted my error pretty quickly but I worry others might not spot it so quickly.

I have thought of some options:

  1. Do nothing. This was user error not a bug
  2. Cast the noise_covar value to a CovarianceMatrix when initialising a MeasurementModel. Using a 1D array would result in a ValueError being throw
  3. Add a warning if a 1D array is used in a measurement model

gawebb-dstl avatar Dec 05 '22 13:12 gawebb-dstl

I think 2. is a good option.

sdhiscocks avatar Jan 30 '23 09:01 sdhiscocks