LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a compounding average for dynamic data

Solved!
Go to solution

Hello all,

 

I am currently trying to create a compounding average for a dynamic data output -- where the average begins to converge to a single value over time. I would like to see a waveform chart that has incoming averages that continually start to reach a stable value as collection time continues. I shall be displaying the averaged data in real time so I would have to be able to do that. Any help would be appreciated as I can only seem to find examples on rolling averages.

 

Thanks. 

0 Kudos
Message 1 of 7
(3,758 Views)

hi acd,

could you formalize what a compounding average is? like with math?


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 2 of 7
(3,751 Views)

Hello jwscs,

Sorry if I was not clear. When I said a "compound average" I really meant a "cumulative moving average". 

 

Data arrives in an orderly data stream and I would like to calculate the average of all data up until the current data point, which in itself moves with time. I would like to attain a graph similar to the example here;

CumulativeMovingAverage002.jpg

 

0 Kudos
Message 3 of 7
(3,727 Views)
Solution
Accepted by topic author acd5371

seems straight forward.

have two variables, that you keep updating every time a new data-point comes in.

 

one for the TOTAL and one for the COUNT of data-points.

 

divide TOTAL by COUNT,

then you display it with your chart/graph.

 

moving-average.png


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 4 of 7
(3,714 Views)

Thank you very much this is what I was looking for. Now if I may extend the question further, how would I adapt this to work where the incoming dynamic data has two different data points (i.e. two pressure readings). I cannot get the shift registers to accept a 2 dimensional array.

0 Kudos
Message 5 of 7
(3,678 Views)

Shift registers will certainly take a 2-D array.  But you want your shift registers to be 1-D arrays.  A 1-D array that contains the totals for your different pressure readings, and a 1-D array that takes the count of your pressure readings.  (Though if each pressure reading has the same number of data points as the others, then you only need a scalar in your shift register to keep track of the count.)

0 Kudos
Message 6 of 7
(3,675 Views)

you can change the initialization for the shift-registers to the datatype you want

(outside the loop change the constant to what you want it to be e.g. constant, 1d-, 2d-array)

 

but if you only have a second measurement, just add another shift-register for the TOTAL2,

and the COUNT should be the same for both.

 

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 7
(3,632 Views)