Esempio n. 1
0
def create_true_params_2x3():
    params = kalman.SSMParameters()
    params.F = np.array([
        [99, 20],
        [-4, -80],
    ])/ 100
    print(np.linalg.eig(params.F))
    params.H = np.array([
        [ -1, 1], 
        [ 0.5, -0.1], 
        [  1.5,  5.0],
    ])
    params.Q = np.array([
        [  10, 0.001],
        [0.001,     1],
    ])
    params.R = np.array([
        [  0.1, 0.007,  0.01],
        [0.007,     5,  0.01],
        [ 0.01,  0.01,   0.1],
    ])
    params.X0 = np.array([
        [87],
        [0],
    ])
    params.P0 = np.array([
        [  0.9, 0.001],
        [0.001,   0.5],
    ])
    params.set_dimensions(3, 2)
    np.random.seed(0)
    T = 200
    X, Y = params.simulate(T)
    return params, X, Y
Esempio n. 2
0
def create_true_params_enders_2x2_true():
    params = kalman.SSMParameters()
    params.F = np.array([
        [0.7, 0.2],
        [0.2, 0.7],
    ])
    params.Q = np.array([
        [0.1, 0.01],
        [0.01, 0.1],
    ])
    params.X0 = np.array([100, 80]).reshape(-1, 1)
    params.P0 = np.array([
        [0.1, 0.01],
        [0.01, 0.1],
    ])
    params.H = np.array([
        [10.0, 0.0],
        [0.1, 1],
    ])
    params.R = np.array([
        [0.01, 0.01],
        [0.01, 0.01],
    ])
    print("Stability of F:", np.linalg.eig(params.F)[0])
    params.set_dimensions(2, 2)
    np.random.seed(0)
    T = 300
    X, Y = params.simulate(T)
    return params, X, Y
Esempio n. 3
0
def create_true_params_1x3():
    params = kalman.SSMParameters()
    params.F = np.array([
        [1 - 1e-3],
    ])
    print(np.linalg.eig(params.F))
    params.H = np.array([
        [ -1], 
        [ 0.1], 
        [  1.0],
    ])
    params.Q = np.array([
        [  100],
    ])
    params.R = np.array([
        [  100, 0.07,  0.01],
        [0.07,     4,  0.01],
        [ 0.01,  0.01,   500],
    ])
    params.X0 = np.array([
        [7],
    ])
    params.P0 = np.array([
        [  0.1 ],
    ])
    params.set_dimensions(3, 1)
    np.random.seed(0)
    T = 300
    X, Y = params.simulate(T)
    return params, X, Y
Esempio n. 4
0
def noising_params(params, factor=0.2):
    np.random.seed(123456)
    noise_params = kalman.SSMParameters()
    noise_params.F = params.F + factor * np.random.randn(*params.F.shape)
    noise_params.H = params.H + factor * np.random.randn(*params.H.shape)
    noise_params.Q = params.Q + factor * np.random.randn(*params.Q.shape)
    noise_params.R = params.R + factor * np.random.randn(*params.R.shape)
    noise_params.X0 = params.X0 + factor * np.random.randn(*params.X0.shape)
    noise_params.P0 = params.P0 + factor * np.random.randn(*params.P0.shape)
    noise_params.set_dimensions(3, 2)
    return noise_params