我已经用在这里implented卡尔曼滤波器:https://gist.github.com/alexbw/1867612卡尔曼滤波行为
我有它的一个非常基本的理解。这是测试代码我有:
import matplotlib.pyplot as plt
import numpy as np
from Kalman import Kalman
n = 50
d = 5
xf = np.zeros(n - d)
yf = np.zeros(n - d)
xp = np.zeros(d)
yp = np.zeros(d)
x = np.zeros(n)
y = np.zeros(n)
for i in range(n):
if i==0:
x[i] = 05
y[i] = 20
KLF = Kalman(6, 2)
elif i< (n - d):
xf[i], yf[i] = KLF.predict()
x[i] = x[i-1] + 1
y[i] = y[i-1] + np.random.random() * 10
NewPoint = np.r_[x[i], y[i]]
KLF.update(NewPoint)
else:
x[i] = x[i-1] + 1
y[i] = y[i-1] + np.random.random() * 10
xp[n - i -1], yp[n - i -1] = KLF.predict()
NewPoint = np.r_[x[i] , yp[n - i -1]]
KLF.update(NewPoint)
plt.figure(1)
plt.plot(x, y, 'ro') #original
plt.plot(xp, yp, 'go-') #predicted kalman
plt.plot(xf, yf, 'b') #kalman filter
plt.legend(('Original', 'Prediction', 'Filtered'))
plt.show()
我的问题是,为何kalman滤波从0开始,如果数据开始在x = 5,Y = 20? 这是一种标准的行为?
由于