473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Dual Kalman Filter

I want to estimate a variable x, and the observable variable y can be obtained from sensors. These two variables has an approximately linear relationship,i.e., y=k*x + b, but k and b are difficult to get, so I use two kalman filters, one for state (x) estimation, another for parameter (k,b) estimation, which actually combines the dual kalman filter. The general scheme and code in Python is as attached, and state estimation kalman filter functions, parameter estimation kalman filter functions are also attached.
Expand|Select|Wrap|Line Numbers
  1. ##Python code
  2. #initialize state estimator
  3. kf = KalmanFilter(dim_x=1,dim_z=1)
  4. kf.x = numpy.array([x0])              # initial state
  5. kf.F = numpy.array([1.])              # state transition matrix
  6. kf.Q = 1000                           # state noise variance,
  7. kf.R = 1                              # measurement noise variance
  8.  
  9. #initialize parameter estimator
  10. dkf = KalmanFilter(dim_x=2,dim_z=1)
  11. dkf.x = numpy.array([[-0.01,-0.1]]).T # initial state 
  12. dkf.F = numpy.array([[1,0],
  13.                     [0,1]])           # state transition matrix
  14. dkf.Q = numpy.array([[1,0],
  15.                     [0,1]])
  16. dkf.R = 100                           # measurement noise variance
  17.  
  18. measurements = []
  19. resultsDKF = []                                         #dual kalman filter state estimation result
  20. ERRDKF = []                                               #estimation error
  21.  
  22. for i in xrange(N):   # N samples
  23.     #### parameter estimator
  24.     dkf.H = numpy.array([[kf.x,1]])   # measurement function
  25.     y = Y[i]
  26.     dkf.update(y,dkf.R,dkf.H)        
  27.     dkf.predict()
  28.  
  29.     #### state estimator
  30.     kf.H = numpy.array([dkf.x[0]])
  31.     z = Y[i]-dkf.x[1] # Y[i]-b
  32.     kf.update(z,kf.R,kf.H)    
  33.     kf.predict()
  34.  
  35.     #### save data
  36.     measurements.append(Y[i])
  37.     resultsDKF.append (kf.x)
  38.     ERRDKF.append(measurements[-1]-resultsDKF[-1])
It seems that the predicted state varies with the true value, but there still is a big gap between predicted and true value, and if I set the initial state of x (that is x0 in the code) near the true initial value, the results are much better,as attached.

I think the dual kalman filter doesn't really track true values of x, what's the problem? Anybody who offers advice will be much appreciated.
Attached Images
File Type: jpg DKF(English).jpg (5.8 KB, 309 views)
File Type: png stateEstimationKF.png (2.1 KB, 128 views)
File Type: png parameterEstimationKF.png (5.5 KB, 130 views)
File Type: jpg badresults.jpg (46.9 KB, 155 views)
File Type: jpg goodresults.jpg (42.7 KB, 169 views)
Mar 22 '16 #1
1 4029
Is there anybody can help me figure out this problem? I personally think there is something wrong with details.
Mar 23 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Oracle3001 | last post by:
Hi All, I am looking to use a kalman filter to predict the motion of a throw ball. I was wondering if anybody knew of a java implementation of the broad outline of the equations involved in...
9
by: Tomer Ben-David | last post by:
Hi I have a big j2ee appliction that was so forth run on a single cpu machine. I have tested it on a dual cpu machine, its running much slower (about X3 times slower). I know that...
3
by: Yaroslav K. Kravchishin | last post by:
Oracle 7.0.1 Server When I type SQL> select sysdate from dual; SYSDATE --------- 01-OCT-03 01-OCT-03 2 rows selected.
5
by: John Dalberg | last post by:
I am planning to build a server to be used as a SQL Server and web server. Right now I can only use a single box for both. I have read some threads were dual processors are having problems with...
1
by: Mike | last post by:
I have 2 drop downs on my web page and this will allow the user to filter the data on one drop down or both. How can I link these dropdowns together to allow the user to filter on one or both? ...
5
by: JC Voon | last post by:
Hi: I have two combo boxes on screen that when one's selection is change the other's items will be updated to reflect the change dtMaster = .... ds.Tables.Add(dtMaster)
25
by: John Gibson | last post by:
Hi, all. I need to upgrade my dual Xeon PostgreSQL engine. Assuming similar memory and disk sub-systems, I am considering a Quad Xeon system vs. a Dual Itanium for PostgreSQL. I believe that...
5
by: uspensky | last post by:
We are trying to setup a system to system failover cluster using two nodes (x346) which each have a single hba running to seperate controllers on the DS400. For full redundnancy, IBM recommends...
3
by: eytboquiren | last post by:
Hello. I am a student from the philippines and i am currently on my thesis project. Its all about understanding and implementing Kalman Filter on a GPS/INS system using vb 6. I still cannot fully...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.