Jump to content

Deviations of the mean


Recommended Posts

I was recently trying to compare a few ways of calculating a running average. I was surprised that the point-by-point mean was not the same as a 'traditional' mean value. The values are only off at the 10^-15 range which makes me assume that it is a floating point value problem (and makes me feel like I don't need to spend too much time working on it) but I am still surprised that there is a difference at all (especially after the first 4 iterations in my running average (which uses a 4 point buffer).

Please look at my demo VI and see if there is any other explanation. (The VI is in 8.2.1).

Thanks in advance!

Link to comment

QUOTE(Omar Mussa @ Aug 20 2007, 11:41 AM)

I was recently trying to compare a few ways of calculating a running average. I was surprised that the point-by-point mean was not the same as a 'traditional' mean value. The values are only off at the 10^-15 range which makes me assume that it is a floating point value problem (and makes me feel like I don't need to spend too much time working on it) but I am still surprised that there is a difference at all (especially after the first 4 iterations in my running average (which uses a 4 point buffer).

Please look at my demo VI and see if there is any other explanation. (The VI is in 8.2.1).

Thanks in advance!

Even more concerning is that if you lower the millisecond delay to zero and let it run for a little bit, the Mean values 'go out of tolerance'. It looks like the point-by-point mean keeps an array of x values and a running sum. The problem is that it adds the new value to the sum and subtracts the oldest value from the sum, resulting in some rounding errors that accumulate over time. What you end up with is a sum that does not exactly equal the sum of the 4 values.

Link to comment

QUOTE(B Chavez @ Aug 20 2007, 12:31 PM)

Even more concerning is that if you lower the millisecond delay to zero and let it run for a little bit, the Mean values 'go out of tolerance'. It looks like the point-by-point mean keeps an array of x values and a running sum. The problem is that it adds the new value to the sum and subtracts the oldest value from the sum, resulting in some rounding errors that accumulate over time. What you end up with is a sum that does not exactly equal the sum of the 4 values.

I hadn't tried running with a 0 delay... When I did I found that the values are within 10^-13 of each other. Still close enough for me not to care, but you are right about the cumulative effects of add/subtract in ther pop on/off mechanism. I think that additionally, the difference between the values would increase the larger the buffer size you elected to use.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.