-
iterative mean, std (standard deviation)Mathematics 2020. 9. 10. 17:57
Source url : https://math.stackexchange.com/questions/102978/incremental-computation-of-standard-deviation Example # samples samples = [np.random.normal(0, 1) for i in range(100)] # param max_idx = 500 # initialzed vars mu = 0.0 var = 0.0 idx = 1 # run for s in samples: var = (idx - 2)/(idx - 1 + 1e-6) * var + (1/idx)*(s - mu)**2 mu = 1/idx * (s + (idx-1)*mu) idx += 1 if idx == max_idx: idx = ma..
-
Global to Local coordinate, Local to Global coordinateMathematics 2020. 9. 10. 17:45
Basic Concept Base code import numpy as np def get_R(theta): """ theta: [rad] """ R = np.array([ [np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)] ]) return R pos = np.array([1, 0]).reshape(-1, 1) heading_ang = 90 * (np.pi/180) # [rad] R = get_R(heading_ang) inv_R = np.linalg.inv(R) Global to local coordinate # global to local xy_local = np.dot(R, pos) print(xy_local) # [[0], [1]] ..
-
[Kalman filter] code, exampleMathematics 2020. 9. 10. 17:22
아래 예제는 https://pinkwink.kr/781 와 유사합니다. 아래 KalmanFilter class 코드는 https://github.com/zziz/kalman-filter 에서 약간의 수정을 하였습니다. import numpy as np class KalmanFilter(object): def __init__(self, F = None, B = None, H = None, Q = None, R = None, P = None, x0 = None): """ F(=A) [nxn]: system matrix that releates the state at k-1 to the state at step k B [nx1]: it relates the control input(u_k) to the sta..