non-zero elements in the covariance matrix P of unscented kalman filter
I suspect you might get better answers elsewhere, though I'm not sure where.
You can ensure a diagonal state error covariance matrix only in the case that the state is in fact a collection of independent 1 dimensional states with no dynamics (ie the prediction of the state at time t' is the state at time t) and no measurements involve more than one state element.
The essential point of the Kalman filter is that it estimates the correlations between the state errors.
I'm using the unscented kalman filter class of filterpy.kalman library.
Even when I initialize both of the process noise Q and the initial covariance P with off-diagonal entries that are all equal to zero, I still get P and S with non-zero off-diagonal entries, is there a way to ensure that P and S have off-diagonal entries that are all equal to zero?