# Is the state covariance matrix (or estimate uncertainty) in a Kalman filter in 1D equal to the variance of the current normal distribution?

I'm trying to use a Kalman-filter for some kind of anomaly detection. But I think that maybe I have misunderstood something fundamental about the filter. I'm following this "guide".

I'm using the filter in one dimension. It is my understanding that the filter estimates the mean of the state variable x and updates this mean whenever it is given a new measurement z. Moreover it gives an uncertainty p of the estimate and updates this whenever it is given a new measurement. So as I understand it, whenever the estimates are computed I have a model: a normal distribution with the current estimated mean as mean and the current sqrt(p) as standard deviation. And this normal distribution gets updated with every new measurement.

So my question is: can I directly translate the estimate uncertainty to the standard deviation like I do, or doesn't this p have anything to do with the standard deviation?

And if so, how come the estimate uncertainty gets smaller (or the same) in every iteration? I do mathematically understand why, but not why the filter has to behave this way. Say we have some measurements which is normally distributed with mean 7 and standard deviation 1 which suddenly change to a normal distribution with mean 7 and standard deviation 5, just like this figure: If the estimate uncertainty can be translated to the standard deviation of the current normal distribution I would expect p to gradually get bigger when we get to the data with higher variance. But that is not the case: it keeps decreasing. So my only conclusion is that this p doesn't have anything to do with the standard deviation. Is that correct? But then what does p express? In this case, how can I then track the variance as well as the mean, and update it in each iteration?

From what you say I understand you are using the filter given by the equations: $$\alpha_{t+1} = \alpha_t + \eta_t$$ $$y_t = \alpha_t + \epsilon_t$$ with $$\sigma^2_\eta$$ and $$\sigma^2_\epsilon$$ estimated or otherwise set from previos knowledge. Now, the variances the Kalman filter produces at each step are the variances of $$\alpha_t$$, and these should decrease for a while and then (for a time-invariant model, with fixed $$\sigma^2_\eta$$ and $$\sigma^2_\epsilon$$) reach the steady state --become constant. Notice that this behaviour is quite independent from the behaviour of the $$y_t$$'s, the computed variance of the state $$\alpha_t$$ depends only on $$\sigma^2_\eta$$ and $$\sigma^2_\epsilon$$. In fact, it can be pre-computed (and sometimes is) before seeing a single observation.
That said, if your $$y_t$$'s behave like in the graph you show, you probably would want to introduce a regime change at time around 100 (incresing the value of either or both variances $$\sigma^2_\eta$$ and $$\sigma^2_\epsilon$$) and then yes, the variance of the state could increase until you reach the new steady state or a new change of regime.