本文整理汇总了Python中sympy.Matrix.multiply方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.multiply方法的具体用法?Python Matrix.multiply怎么用?Python Matrix.multiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Matrix
的用法示例。
在下文中一共展示了Matrix.multiply方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: symbols
# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import multiply [as 别名]
import numpy as np
from sympy import Matrix, symbols, S
H = np.array([0, 1])
s1, s12, s2, r2 = symbols("s1 s12 s2 r2")
Pk_pre = Matrix([[s1, s12], [s12, s2]])
Hk = Matrix(H)
print("Pk(-) =\n" + str(Pk_pre))
print("Hk = " + str(Hk))
Kk = (Pk_pre.multiply(Hk.transpose())) * (S(1) / ((Hk.multiply(Pk_pre)).multiply(Hk.transpose())[0] + r2))
print("Kalman gain:\n" + str(Kk))
Pk_post = (Matrix([[1, 0], [0, 1]]) - Kk.multiply(Hk)).multiply(Pk_pre)
print("Pk(+) =\n" + str(Pk_post.expand()))
N = 2 ** 10 # number of points
r2 = 0.1 # variance r2 = sigma**2
v = np.random.normal(0.0, r2 ** 0.5, (N,))
# True state, constant
x = np.ones((N, 2))
x[:, 0] *= 0.5
x[:, 1] *= 0.25
print("Initial state: x[0] =\n{0}".format(x[0]))
# Estimated state, initially within 5% of true state
x_est = np.zeros((N, 2))
x_est[0] = x[0] + (np.random.rand(2) * 0.1 - 0.05) * x[0] # really x_est_0_post
print("A posteriori initial state estimate: x_est_0(+) =\n{0}".format(x_est[0]))