Page 1 of 4 1234 LastLast
Results 1 to 15 of 55

Math Help - Kalman filtering application

  1. #1
    Junior Member
    Joined
    Feb 2009
    Posts
    33

    Kalman filtering application

    Dear all

    I am doing a project which is about energy comsumption estimation.
    First, I need to read all parameters available in different time instant, i.e. x1(ti), x2(ti), x3(ti),... x6(ti) etc. ti means time at the ith interval. Suppose x6 represents power consumption at that instant while i believes that x6 is the dependent variable while x1, x2, .... x5 are all independent variables.

    Then, i can formulate a linear equation, like x6 = a x1 + b x2 +c x3 + d x4 + e x5. Since i can get data for a series of time, say i = 1 to 100. Then, i can have 100 linear equations. Kalam filter is used to estimate a, b, c, d and e. Once their values are know, i can preduct x6(t101) based on x1(t101), x2(t101), ....x5(t101).

    Then, i can compare such x6 at t101 with the real x6 from the simulator. Since it is a linear approximation, a, b, c, d and e will keep on changing. So, i need to write a program to keep track of these five constants and do predict. Then plot the graph of predicted x6 with the real x6 to finish my work.

    Since i am new to Kalman filter, i have no idea how can i start my job with the filter. Can you guys give me some guidance how to start? I have read many materials about kalman filter, but i don't know which aspects of kalman filter is applicable to my project.....

    Thank you
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by atlove View Post
    Dear all

    I am doing a project which is about energy comsumption estimation.
    First, I need to read all parameters available in different time instant, i.e. x1(ti), x2(ti), x3(ti),... x6(ti) etc. ti means time at the ith interval. Suppose x6 represents power consumption at that instant while i believes that x6 is the dependent variable while x1, x2, .... x5 are all independent variables.

    Then, i can formulate a linear equation, like x6 = a x1 + b x2 +c x3 + d x4 + e x5. Since i can get data for a series of time, say i = 1 to 100. Then, i can have 100 linear equations. Kalam filter is used to estimate a, b, c, d and e. Once their values are know, i can preduct x6(t101) based on x1(t101), x2(t101), ....x5(t101).

    Then, i can compare such x6 at t101 with the real x6 from the simulator. Since it is a linear approximation, a, b, c, d and e will keep on changing. So, i need to write a program to keep track of these five constants and do predict. Then plot the graph of predicted x6 with the real x6 to finish my work.

    Since i am new to Kalman filter, i have no idea how can i start my job with the filter. Can you guys give me some guidance how to start? I have read many materials about kalman filter, but i don't know which aspects of kalman filter is applicable to my project.....

    Thank you
    Identify the state vector, the measurement matrix, the measurement (co)variance and if possible any prior knowlege of the state (so we can initialise the state and its covarianve matrix).

    Also you may have to identify the state kinematics (looks like your have a stationary state so we already have that).

    Then you just use the equations from the book (assuming we can treat the plant noise as non-existant).

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Feb 2009
    Posts
    33
    Sorry for disturbance and thank you for your reply.
    Do you mind to give me some information about how to determine state vector, the measurement matrix, the measurement (co)variance and state kinematics?
    I have found some of them but don't really know what that means....
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by atlove View Post
    Sorry for disturbance and thank you for your reply.
    Do you mind to give me some information about how to determine state vector, the measurement matrix, the measurement (co)variance and state kinematics?
    I have found some of them but don't really know what that means....
    Your state vector is a column vector containing all the information needed to describe the system, here that is {\bf{X}} = [a,b,c,d,e]^T, the measurement matrix is the matrix \bf{H} such that:

    z={\bf{HX}}+w

    where z is what is measured in this case x_6 and w is the measurement error/noise. So for this problem it is the row vector: {\bf{H}}=[x_1,x_2,x_3,x_4].

    In your case as the state is just a vector of constants there is no kinematics, and so if you use the eqaations form a text the state propagation matrix is:

     <br />
{\bf{\Phi}}={\bf{I}}_{5,5}<br />

    CB
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    Feb 2009
    Posts
    33
    how to work out the w?
    Is the z={\bf{HX}}+w the process equation ? Is it necessary to find the measurement equation? Y(K)=H(K) X(K) + V(K) where k is time variable, y-noise measurement of x, H-measurement matrix, v-noise. If it do, how to determine it? thank you
    Last edited by mr fantastic; February 21st 2009 at 05:09 AM. Reason: Fixed up the various typesetting problems.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by atlove View Post
    how to work out the w?
    Is the z={\bf{HX}}+w the process equation ? Is it necessary to find the measurement equation? Y(K)=H(K) X(K) + V(K) where k is time variable, y-noise measurement of x, H-measurement matrix, v-noise. If it do, how to determine it? thank you
    There will be a lot of confusion as there are a large number of conventions on the notation. Your Y(K) is my z. I also drop the K from my notation, as this is a sequantial process, and the update always always referes to the current measurement the prior estimate of the state and generates a posterior mesurement of the state.

    The measurement error/noise my z and your V should be known processes and so the variance should be known.

    CB
    Last edited by mr fantastic; February 21st 2009 at 05:10 AM.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Junior Member
    Joined
    Feb 2009
    Posts
    33
    it'seems that the idea of kalman filtering you proposed has some difference with mine.

    do you mind to read the following website to get what 's my idea?
    KALMAN FILTERS

    This website showed one equation (the dynamic equation) to estimate the measurement of posterior with prior estimation of state , another equation(y(k)=Mx(t1)+w(1)) is the measurement of noise in estimating X. Do the idea proposed in this website applicable to my project?

    can you give me an example of measurement noise?

    thank you
    Last edited by atlove; February 21st 2009 at 06:58 PM. Reason: add question
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by atlove View Post
    it'seems that the idea of kalman filtering you proposed has some difference with mine.

    do you mind to read the following website to get what 's my idea?
    KALMAN FILTERS

    This website showed one equation (the dynamic equation) to estimate the measurement of posterior with prior estimation of state , another equation(y(k)=Mx(t1)+w(1)) is the measurement of noise in estimating X. Do the idea proposed in this website applicable to my project?

    can you give me an example of measurement noise?
    You have no dynamic, that site's F is my \bf{\Phi} and as there is no dynamic in this case if we insist on using it it is the identity transfoem. Also as far as I am aware you have no plant noise (u(k) in that sites notation, which represents the (unknown and modelled as random) divergence of the true state from the state that the dynamic predicts).

    That site's M is my \bf{H} which I beleive is the more common notation, and we agree on w.

    Note that the site you quote is only presenting a 1-D KF, you need the multi-dimensional case.

    can you give me an example of measurement noise?
    I want to measure the height of one of my children so we mark their height on the door post and measure that height with a extending steel rule. So if their true height is h_t and I measure height h_m we have:

    h_m=h_t+w

    where w represents the error in this measurement process. This error is composed of multiple terms, lets say the accuracy of making the mark, and that of reading the height on the rule. What is important is the distribution of this error, we would hope it has zero mean, and has a standard deviation we can estimate. After thinking about how the mark is made we may conclude that the standard deviation of that is \approx 1 \text{cm} and that the standard deviation of reading the rule is \approx 0.25 \text{cm}, so the SD of w is \approx 1.03 \text{cm}. For convienience we also assume that w is normally distributed so we have assumed: w \sim N(0,1.03^2).



    I would suggest that you try to find a copy of Applied Optimal Estimation by Gelb et al. which in my opinion contains the very best presentation of the practical (as well as theoretical) aspects of Kalman filtering.


    CB
    Last edited by CaptainBlack; February 22nd 2009 at 01:41 AM.
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Junior Member
    Joined
    Feb 2009
    Posts
    33
    ThX for the book, i found the book in my campus library fortunately

    I will read this book first.

    Thank you
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Junior Member
    Joined
    Feb 2009
    Posts
    33
    CaptainBlack
    do you have some example about the application of kalman filtering which somehow similar to my project?

    i have read many material , i want some example to further my understanding.

    if you don't have , just leave it, doesn't matter,

    thank you very much
    Follow Math Help Forum on Facebook and Google+

  11. #11
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by atlove View Post
    CaptainBlack
    do you have some example about the application of kalman filtering which somehow similar to my project?

    i have read many material , i want some example to further my understanding.

    if you don't have , just leave it, doesn't matter,

    thank you very much
    No, all the applications I have used are to target tracking and bearings only analysis.

    CB
    Follow Math Help Forum on Facebook and Google+

  12. #12
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by atlove View Post
    CaptainBlack
    do you have some example about the application of kalman filtering which somehow similar to my project?

    i have read many material , i want some example to further my understanding.

    if you don't have , just leave it, doesn't matter,

    thank you very much
    I have implemented a 2-D verion of your problem in Matlab, the code follows:

    Code:
    function rv=DataGen
    x=rand(1,2).*20;
    y=sum(x)+randn(1,1);
    rv=[x,y];
    This generates a data set such that the third element is the sum of the first two plus a normally distributed random number of unit variance.

    (the model is d_3=d_1+d_2+w, I use d here as x is usually reserved for the state )

    Code:
    function [X,P]=KalmanInov(Data,R,X,P)
    %
    % Kalman Filter Inovation Processing
    %
    %
    %
      H=[Data(1),Data(2)];  %extract the H matrix or vector from the data
      z=Data(3);                %extract the measurement from the data
     
    % Below is the standard Kalman inovation equations in matrix form
     
    
      S=H*P*H'+R; %note this is a scalar
      K=P*H'*inv(S);
      X=X+K*(z-H*X);
      P=(diag([1,1])-K*H)*P;
    The above is the Kalman innovation process straight from the book X on input is the old state estimate, and on exit the new state estimate, and P on input is the prior state covariance matrix and on exit is the posterior state estimate.

    Code:
    function rv=KalmanSim
    
      P=[100,0;0,100]; %initial covariance of state estimate
      X=[0;0];            %initial state estimate
      R=1;                 %measurement variance
    
      rv=X
    
      for idx=1:10
        D=DataGen;     % generate some data
        [X,P]=KalmanInov(D,R,X,P);
        rv=[rv,X];        %accumulate the state estimate
      end
    The above loops over 10 sets of data, plotting the rows of the returned matrix will show the evolution of the state estimate, which tend to [1,1]'

    Note there is no need for a dynamic with this model.

    The attached figure shows the evolution of the components of the state estimate.

    CB
    Attached Thumbnails Attached Thumbnails Kalman filtering application-gash.jpg  
    Follow Math Help Forum on Facebook and Google+

  13. #13
    Junior Member
    Joined
    Feb 2009
    Posts
    33
    CaptainBlack, thx for spending time on making such a simulation.

    I need to read some matlab material to check what the code actually doing.

    Is your code use many built-in functions from matlab? since i didn't see any calculation within the code.
    Follow Math Help Forum on Facebook and Google+

  14. #14
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by atlove View Post
    CaptainBlack, thx for spending time on making such a simulation.

    I need to read some matlab material to check what the code actually doing.

    Is your code use many built-in functions from matlab? since i didn't see any calculation within the code.
    No, but it does use the built in matrix arithmetic operators and random number generators.

    CB
    Follow Math Help Forum on Facebook and Google+

  15. #15
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by atlove View Post
    CaptainBlack, thx for spending time on making such a simulation.

    I need to read some matlab material to check what the code actually doing.

    Is your code use many built-in functions from matlab? since i didn't see any calculation within the code.
    What language were you intending to program this in?

    (by the way I now have a version of the filter in Matlab and the simulation which operates with the full model of you original post)

    CB
    Follow Math Help Forum on Facebook and Google+

Page 1 of 4 1234 LastLast

Similar Math Help Forum Discussions

  1. particle filtering
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: December 9th 2009, 11:41 PM
  2. Kalman Gain
    Posted in the Advanced Statistics Forum
    Replies: 6
    Last Post: June 5th 2009, 08:31 AM
  3. Account for latency in Kalman Filter
    Posted in the Advanced Statistics Forum
    Replies: 2
    Last Post: March 16th 2009, 03:56 AM
  4. Mathematica - 2 Questions: Filtering & Headers
    Posted in the Math Software Forum
    Replies: 2
    Last Post: October 24th 2008, 02:29 PM
  5. Filtering the top 5% in real-time
    Posted in the Advanced Math Topics Forum
    Replies: 1
    Last Post: July 9th 2008, 07:42 AM

Search Tags


/mathhelpforum @mathhelpforum