Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if i want get the final A and kalman gains ,what should i do ? #11

Closed
shenjianaixuexi opened this issue Dec 27, 2019 · 2 comments
Closed

Comments

@shenjianaixuexi
Copy link

I want to get A MATRIX and kalman gains ,what should i do?

@oseiskar
Copy link
Owner

The A matrix should be given by you in the filter constructor parameter state_transition. The Kalmain gains can obtained by using the general function compute. Both the smoothing and filtering gains are available. This was not documented very clearly, I'll have to fix that at some point. Here's an example

import numpy as np
import simdkalman
import pandas as pd
import matplotlib.pyplot as plt

np.random.seed(0)
data = np.random.normal(size=50)

kf = simdkalman.KalmanFilter(
    state_transition = [[1,1],[0,1]],        # <--- this is the matrix A
    process_noise = np.diag([0.05, 0.002]),  # Q
    observation_model = np.array([[1,0]]),   # H
    observation_noise = 20.0)

result = kf.compute(data, 0, filtered=True, smoothed=True, gains=True)

t = range(data.size)
plt.plot(t, data, 'kx', alpha=0.2)
plt.plot(t, result.filtered.observations.mean, 'b-')
plt.show()

# filtering gains
print(result.filtered.gains)

# smoothing gains
print(result.smoothed.gains)

@shenjianaixuexi
Copy link
Author

thanks for your help. I will try it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants