python ⽆迹卡尔曼(filterpy.kalman.UnscentedKalmanFi 。。。
python ⽆迹卡尔曼(Undescented kalman fliter )主要函数调参520表白日
1. filter.kalman.MerweScaledSigmaPoints ,Van der Merwe 式sigma 点选择,UT 变换最好⽤的sigma 点选择算法空调寿命
input:
n :状态维度
alpha :均值附近sigma点的分布,通常选0.1~1之间。调节中⼼点与周围点的权重。
beta :由先验知识,⾼斯分布选2。
kappa :k = 3-n
output:
Wm :sigma点均值的权重
元旦策划书Wc :sigma点协⽅差的权重
可以看到,sigma点介于
第⼀和第⼆标准差。越⼤,中⼼点越突出,所占权重配⽐越⼤。
2.filter.kalman.UnscentedKalmanFilter ,UKF 类
输⼊参数:
藠头dim_x :2维滤波,dim=4
dim_ z:2维滤波,dim=2
dt : 时间差
押运公司hx:function(x)
fx:function(x, dt)
points:点类,就是MerweScaledSigmaPoints⽣成的点
特征参数:
x:numpy.array(dim_x), 状态估计向量
P: numpy.array(dim_x, dim_x),协⽅差估计矩阵
Q: numpy.array(dim_x, dim_x),过程噪声矩阵
R: numpy.array(dim_z, dim_z),测量噪声矩阵
K: 卡尔曼增益矩阵
y:残差矩阵
3.举例:
α
from filterpy.kalman import KalmanFilter
import Q_discrete_white_noi
from numpy.random import randn
import numpy as np
from numpy.random import randn苹果原产地
from filterpy.kalman import UnscentedKalmanFilter
import matplotlib.pyplot as plt
from filterpy.kalman import UnscentedKalmanFilter as UKF
漏网之鱼的意思
from filterpy.kalman import unscented_transform, MerweScaledSigmaPoints
def f_cv(x, dt):
""" 匀速直线运动函数"""
F = np.array([[1, dt,0,0],
[0,1,0,0],
[0,0,1, dt],
[0,0,0,1]])
return F @ x
def h_cv(x):
return x[[0,2]]
std_x, std_y =.3,.3
dt =1.0
zs =[np.array([i + randn()* std_x,
i + randn()* std_y])for i in range(100)]
np.random.ed(1234)
sigmas = MerweScaledSigmaPoints(4, alpha=.1, beta=2., kappa=1.)
ukf = UKF(dim_x=4, dim_z=2, fx=f_cv,
hx=h_cv, dt=dt, points=sigmas)
ukf.x = np.array([0.,0.,0.,0.])
ukf.R = np.diag([0.09,0.09])
ukf.Q[0:2,0:2]= Q_discrete_white_noi(2, dt=1, var=0.02)
ukf.Q[2:4,2:4]= Q_discrete_white_noi(2, dt=1, var=0.02)
uxs =[]
for z in zs:
ukf.predict()
ukf.update(z)
象棋玩法uxs.py())
uxs = np.array(uxs)
plt.plot(uxs[:,0], uxs[:,2])
print(ukf)