# Confusion regarding usage of Mahalanobis distance for update rejection in Kalman filtering

I recently came across some material that discussed a method for performing update rejection in Kalman filters when bad measurements are received. [Paper 1] [Paper 2: see Section III(E)] This method involves the usage of Mahalanobis distance to decide whether or not a newly obtained measurement is an 'outlier'.

As per my understanding, the method goes as follows: when a new measurement is obtained, the difference between the observed and predicted measurements: $$(z^{i} - \hat{z}^{i})$$ is combined with the innovation covariance $$S$$ that is computed after the prediction step as

$$\gamma_k = (z^{i} - \hat{z}^{i})^{T}S^{-1}(z^{i} - \hat{z}^{i})$$

Moving forward, the method states that assuming the process/measurement noises are Gaussian distributed (as is standard for Kalman filters), $$\gamma_k$$ should be Chi-square distributed with $$m$$ degrees of freedom (which incidentally should also be the rank of $$S$$). So the method concludes that: for a pre-set confidence interval $$\alpha$$, if $$\gamma_k$$ were to exceed the $$\alpha$$-quantile of the Chi square distribution for $$m$$ degrees of freedom, it should be treated as an outlier and can be rejected.

Hence, for example, for a system with 2 degrees of freedom and assuming 1% confidence threshold, this essentially states that if the value of $$\gamma_k$$ ends up being more than 9.2 (ref: Chi square quantile table), the measurement has a 99% probability of being an outlier. I am confused by how this constant value is valid within the Kalman filter framework; because while $$(z^{i} - \hat{z}^{i})$$ is definitely representative of how 'far' a measurement is compared to the prediction, $$S$$ depends entirely on the confidence of the filter till the current instant.

$$S_k = H*\hat{P}_k*H^T + R_k$$

If the filter is receiving good measurements till time instant $$k$$, and the system is confident enough about the states, the predicted covariance $$\hat{P}_k$$ should be a low value, ($$H$$ is a constant anyway) which makes $$S$$ dependent entirely on the measurement noise covariance, which is user choice: so how is the number 9.2 significant here?

I tried out the Mahalanobis distance method in a pose estimation system for a robot with six degrees of freedom: and when I received some obviously wrong 'outlier' measurements, I was able to spot the spike in the value of $$\gamma$$, but it was nowhere close to the value for deciding if it was an outlier corresponding to six degrees of freedom (which is 16.8 for 1% threshold): instead, it was around 0.2. Am I wrong in my understanding/implementation of how update rejection works in this context?