Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8982789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:39:57+00:00 2026-06-15T20:39:57+00:00

I am using the following smoothing function to smooth speed readings from GPS. void

  • 0

I am using the following smoothing function to smooth speed readings from GPS.

void smoothing_init()
{
    k = 0;
    kalman_init(0.0625, 32, 1.3833094, 0);
}

void kalman_init(double _q, double _r, double _p, double intial_value)
{
    q = _q;
    r = _r;
    p = _p;
    x = intial_value;
}


double smoothing_add_sample(double measurement)
{
    p = p + q;
    k = p / (p + r);
    x = x + k * (measurement - x);
    p = (1 - k) * p;
    return x;
}

However, sometimes this gives me smoothing values 700(the normal range is 0-150) and then going down. I guess it happens when I initialize routine with 0 but immediately receiving reading above 0 (for example 40, 50).

How can I tweak those functions to naturally prevent such spikes, but still be able to smooth data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:39:59+00:00Added an answer on June 15, 2026 at 8:39 pm

    The Kalman filter is an estimator, which minimizes the variance (p in your code) of a system state (x) of a linear system. The variance p can be interpreted as a measure of confidence in the value of x.

    For each time step k the filter performs two steps:

    1. The prediction step propagates the estimate one time step ahead (in your case according to x[k+1] = x[k] + w[k] where w[k] is zero-mean Gaussian noise with variance q). It means here that the state variance is increased by q.
    2. The filtering step incorporates measurement information (according to measurement[k] = x[k] + v[k] where v[k] is zero-mean Gaussian noise with variance r).

    For classic estimation problems p is initialized with a very large value (little confidence in the initial value x). Over time p decreases to a value somewhere around q. Note the p is independent of the measurement, so it only depends on q,r and p[0].

    So for the tweaking:

    • Initialize with a large p, i.e. p/r>>0; the initialization value of x does not really matter.
    • The quotient r/q adjusts how strong the smoothing is (r/q=0 then there’s no smoothing at all).
    • To choose the magnitude of r,q, you can assume Gaussian noise: Then you have a 95% probability the true value lies in the confidence interval of [x-2*sqrt(p), x+2*sqrt(p)].
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using the following function which is based on an example from the
I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
HI, I am using the following code request.js var request; function runAjax(JSONstring) { //
I'm using the following function to brighten up color values (it's a lambda in
I am using the following AS code to call a javascript function which will
I'm currently using the following function to set a timeout inside of a change
I am using the following functions: function loop_perms(permissions) { .... call check_perm here.... }
I am using the following selector: $('a[data-href=/C003Q/History]').click(function(){ alert(clicked); });​ This finds the link with
I am using the following namespacing pattern: var MyNamespace = new function () {
I'm generating two matrices using the following function (note some code is omitted): srand(2007);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.