average FIFO or just add and divide

From post 11 I assume you had already coded a rolling average with a FIFO. Are you recoding or just trying to understand the difference between a rolling average and a batch average?

Yes I want to understand the difference!

Here's another one. If you start the hour at 30C and you end the hour at 32C then your average for the hour is 31C. But if you spent most of the hour at 35C then is the average still 31C? A physicist might say yes and an engineer might say no. So it's always best to understand exactly what is needed and that average means different things in different contexts and code accordingly.[/quote]
Yes that makes for more thought Thanks for keeping me thinking,
Matt
 
Advantages

The add and divide method and similar are what DSP people call an IIR filter or infinite impulse response because even data from way back affects the current value. The advantage of the IIR filter is that it takes few calculations and little storage. The disadvantage is that the last data has more affect than the past data. Sometimes this is desired.

Batch averaging is when you accumulate a lot of readings then divide by the number of readings. This method is simple but the data acquired long ago has the same weight as the recent data. Also one must wait until the desired number of readings are taken before computing the average. I rarely use this kind of averaging or filtering. DSP people call this a FIR filter or finite impulse response filter because the is a finite time back where a reading will have an affect on the output.

The rolling average requires a FIFO or circular queue the way I do it. I also use an accumulator. Each time I get a new reading I take one value out of the FIFO or circular queue and subtract it from the sum. I then put the new value into the FIFO or circular queue and add it to the sum. Then I divide by the number of readings in the FIFO or circular queue. The advantage of this method is that the average is updated every time there is a new reading and one DOES NOT need to sum all the readings in the FIFO or circular queue.

The problem with most filtering, averaging or smoothing is that there is a lot of phase delay. This is occurs when the calculated average does not truly reflect the current value.

Those that pay attention to my posts know that I have much more sophisticated methods of averaging, smoothing or filtering. I need to filter such the phase delay is minimized or 0.
 

Similar Topics

Does this instruction calculate values during a single scan, or does it require number of scans based on element count in the array? For Example...
Replies
3
Views
118
I am working on a program in Cscape to take a pulse input from a flow meter and output an average of the last 5 minutes of flow and total flow to...
Replies
1
Views
575
I am storing values into an array. I am wanting to find an average of the highs and an average of the lows. Something like this... After 50...
Replies
36
Views
8,896
I need to keep a running pass/fail yield of the previous 5,000 parts produced. I have used this formula before to calculate average: AvgValue =...
Replies
6
Views
2,163
is it possible to capture a value while its constantly changing then taking its highest reading? I have a nozzle that sprays for 10 seconds. I...
Replies
14
Views
3,444
Back
Top Bottom