From 73d1c844b071fcd234fff245eab710915faf7687 Mon Sep 17 00:00:00 2001 From: jens Date: Wed, 16 Dec 2020 09:07:52 +0100 Subject: [PATCH] - improved Kalman eval --- components/pid/kalman_eval.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/pid/kalman_eval.py b/components/pid/kalman_eval.py index f350530..562982c 100644 --- a/components/pid/kalman_eval.py +++ b/components/pid/kalman_eval.py @@ -5,8 +5,7 @@ from matplotlib.pyplot import plot, figure, subplot, legend, grid, show T_true = 72 T_est = 68 E_est = 2 -E_mea = 0.5 -k_var = 0.5 +E_mea = 2 _t = np.empty(0) _T_true = np.empty(0) @@ -14,11 +13,11 @@ _KG = np.empty(0) _T_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_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 KG = E_est / (E_est + E_mea) @@ -26,7 +25,7 @@ for t in range(0, 1000): # 2: Calculate estimation 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 _KG = np.append(_KG, KG)