Eugene, I was just looking over the code for Kalman filter and realized that it is very simple to slow it down. At present, the measurement noise is set at the default value of .1:
measurement_noise_cov = Matrix.identity(mp, mp, 1e-1); To slow it down, just use the setter method in JKalman to set it to a higher value: public void setMeasurement_noise_cov(Matrix measurement_noise_cov) The higher the measurement noise, the slower the filter. So, you can have equivalent of a long term average and a short term average. ________________________________ From: Astor <[email protected]> To: [email protected] Sent: Sun, October 24, 2010 8:19:43 PM Subject: Re: [JBookTrader] Re: Status of Kalman filter? No, the control at each step is the price at that step. In EMA, the EMA for this step is EMA from the last step averaged with the price from this step. In Kalman, similarly, the Kalman from last step is averaged with the price (in Kalman lingo, - control) from this step. There are several ways to slow down the Kalman filter. Our current implementation does not have that feature but it is simple to add. The speed of adjustment in Kalman filter, just as in EMA is controlled by the averaging constant K, (which in Kalman lingo is called Kalman gain matrix). For scalar kalman, the matrix is just one number K. Setting the ceiling above which kalman gain K can not go will set the upper (but not the lower) limit on the speed. i.e. K = max(K, ULimitK). ULimitK is some constant which can be tweeked to set the desired speed maximum. Similarly, lower limit on the speed can be added by setting K = min(K, LLimitK) . If such hard limit on speed is undesirable, the measurement noise R can be scaled up by some constant, i.e. R = L*R, where L is some constant that can be set to tweek the speed. I am still looking through the code to find the most suitable place for such modification. ________________________________ veFrom: Eugene Kononov <[email protected]> To: [email protected] Sent: Sun, October 24, 2010 7:04:01 PM Subject: Re: [JBookTrader] Re: Status of Kalman filter? Ok, thanks. I was actually looking for a way to make it less responsive, not more responsive. From your explanation, it sounds like my control should be the price in the past. Is that right? On Sun, Oct 24, 2010 at 7:43 PM, Astor <[email protected]> wrote: Looks good. The filter can be made a bit more responsive by using the constructor and methods which allow "control". > >The term "control" is really misleading. The "control" is simply new >information >that influences the forecast. Using EMA analogy, if EMA(t) = EMA(t-1) + >K*[X(t) >- EMA(t-1)], then X(t) is the "control" in this equation. Why the name >"control"? In some applications, such as missile guidance, X(t) may represent >thrust added at each time t by the targeting computer to control the missile >trajectory. > >If control is omitted then the prediction stage is run as simple >auto-regression >and X(t) enters at the correction stage. If control is included, then X(t) >enters at both, prediction and correction stages, causing filter to respond >quicker. > >For price data from Eugene's test, control is the new price at time t and the >constructor should be: > >JKalman kalman = new JKalman(1, 1,1); > >and predict method: > >s = kalman.Predict(price); > > > > > > > > > > > > ________________________________ From: Eugene Kononov <[email protected]> >To: [email protected] >Sent: Sat, October 23, 2010 9:41:14 AM > >Subject: Re: [JBookTrader] Re: Status of Kalman filter? > > >Based on Astor's comments, I made some changes to the indicator. From the >attached chart, it looks like it's doing a good job. > > > >-- >You received this message because you are subscribed to the Google Groups >"JBookTrader" group. >To post to this group, send email to [email protected]. >To unsubscribe from this group, send email to >[email protected]. >For more options, visit this group at >http://groups.google.com/group/jbooktrader?hl=en. > > >-- >You received this message because you are subscribed to the Google Groups >"JBookTrader" group. >To post to this group, send email to [email protected]. >To unsubscribe from this group, send email to >[email protected]. >For more options, visit this group at >http://groups.google.com/group/jbooktrader?hl=en. > -- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en. -- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en. -- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en.
