I have implemented with a simple code a Kalman Filter for time domain, based on these:
- KG = error_est / (error_est+error_measurment)
- estimate = estimate_prev + KG ( measurment - estimate_prev)
- error_est = (1 - KG) * error_est_prev
The simple code to implement is :
error_est = 1.0 error_measurment = 1.0 estimates =  start = 50.0 # loop over data array of numbers such as [1,2,3,4,..] for index in range(len(data)): measurment = data[index] prev_estimate = estimates[index-1] if index>0 else start KG = error_est / (error_est+error_measurment) estimate = prev_estimate + KG * ( measurment - prev_estimate) estimates.append(estimate) error_est = (1.0 - KG) * error_est
Now I have 3 questions,
The filter is extremely slow, which mean for array of
[1...50], I will get a result of
[1...25], and generally it is much slower than moving average, but i read that it's advantage is that it is fast. What am i doing wrong?
I read that Kalman is used to estimate next result, but how is it possible that a filter ( based on the past) can be used to estimate the next result ?
Are there any parameters you can add to tweak it (such as window in MA) ?