06-20-2017 08:05 AM - edited 06-20-2017 08:12 AM
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.
Solved! Go to Solution.
06-20-2017 08:16 AM
hi acd,
could you formalize what a compounding average is? like with math?
06-20-2017 09:08 AM
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;
06-20-2017 09:19 AM - edited 06-20-2017 09:21 AM
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.
06-21-2017 12:33 PM
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.
06-21-2017 12:41 PM
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.)
06-22-2017 03:14 AM
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.