-
Euler's Method, 오일러 방법, 오일러 적분Mathematics 2020. 9. 10. 23:56
Overview 미분방정식 $\frac{dy}{dx}=f(x, y)$의 수치해를 구하는 방법 작은 상수 $h$를 고정 $x_{k+1}=x_k+h$라 두자 초기값 $(x_0, y_0)$가 주어져 있을 때, 다음의 식을 이용하여 수치해를 구함. $\therefore y_{k+1}=y_k+hf(x_k, y_k)$ Example import numpy as np import matplotlib.pyplot as plt # expression y = lambda x: 2**x y_diff = lambda x: (2**x)*np.log(2) # derivative of exp # settings h = 0.1 x_range = np.arange(0, 3, 0.1) # initial value init_x = x_r..
-
Butterworth Filter explained with codesMathematics 2020. 9. 10. 23:45
Explanation The following ms-word file explains the Butterworth filter up to 2nd order as kindly as possible. It also contains Python codes for the implementation of the filter to filter time series. In short, It deals with both base-knowledge and actual implementation. Implementation in Jupyter
-
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..