- improved Kalman eval

This commit is contained in:
jens
2020-12-16 09:07:52 +01:00
parent f43b866023
commit 73d1c844b0
+4 -5
View File
@@ -5,8 +5,7 @@ from matplotlib.pyplot import plot, figure, subplot, legend, grid, show
T_true = 72 T_true = 72
T_est = 68 T_est = 68
E_est = 2 E_est = 2
E_mea = 0.5 E_mea = 2
k_var = 0.5
_t = np.empty(0) _t = np.empty(0)
_T_true = np.empty(0) _T_true = np.empty(0)
@@ -14,11 +13,11 @@ _KG = np.empty(0)
_T_est = np.empty(0) _T_est = np.empty(0)
_E_est = np.empty(0) _E_est = np.empty(0)
for t in range(0, 1000): for t in range(0, 10000):
_t = np.append(_t, t) _t = np.append(_t, t)
_T_true = np.append(_T_true, T_true) _T_true = np.append(_T_true, T_true)
T_meas = T_true + k_var*np.random.randn() T_meas = T_true + E_mea*np.random.randn()
# 1: Calculate Kalman gain KG # 1: Calculate Kalman gain KG
KG = E_est / (E_est + E_mea) KG = E_est / (E_est + E_mea)
@@ -26,7 +25,7 @@ for t in range(0, 1000):
# 2: Calculate estimation T_est # 2: Calculate estimation T_est
T_est = T_est + KG*(T_meas - T_est) T_est = T_est + KG*(T_meas - T_est)
# 3: Calulate error in estimate E_est # 3: Calculate error in estimate E_est
E_est = (1-KG)*E_est E_est = (1-KG)*E_est
_KG = np.append(_KG, KG) _KG = np.append(_KG, KG)