01-17-2019 11:06 PM
The current problem is that when there are more and more equivalent measurement values and the standard deviation, average, maximum and minimum values are calculated, there will be more and more slow. The picture is the is my use way .Is there has other better way? How can i speed up the calculation?
Solved! Go to Solution.
01-18-2019 12:29 AM
Initialize your array before the loop. Then use replace array subset to insert.
You might want to do your math on a array subset according to the index of the loop.
Try and let me know.
Benoit
01-18-2019 01:14 AM
Hi hnint,
the standard deviation, average, maximum and minimum values are calculated,
For mean, min and max you only need to store their previous (scalar!) value to calculate to new value with the next sample. No need to reevaluate the whole array again!
I guess you could also apply that to stdev and variance too, but never did that on my own before…
01-18-2019 01:20 AM
Please keep in mind that the function for calculating mean sums up all array elements. If your array is big enough you will exceed the limit of your datatype double and you will end up with a wrong mean.
01-18-2019 01:20 AM
My idea is to average every 10,000 pens and then use calculated value with the new 10,000 data. I don't know if this is feasible or not. It is very similar to GerdW, but it still needs to be verified.
01-18-2019 03:09 AM
Change that Insert into array to Build array and compare. The average can be checked with a running average, which only requires 1 add and 1 divide for each element added. Max and Min also only need to be check against the newest element.
/Y
01-18-2019 03:25 AM
01-18-2019 04:36 AM
@thols MeanPtByPt has an internal array of 100 elements (per default), so it might be inaccurate if the array is large.
/Y
01-18-2019 04:41 AM
@Yamaeda wrote:
@thols MeanPtByPt has an internal array of 100 elements (per default), so it might be inaccurate if the array is large.
/Y
So set sample length to Inf.
01-18-2019 05:25 AM
Yes, that works unless the data copy creates issues. The VI's, both MeanPtByPt and StdDevPtByPt are open code, so you can e.g. modify it to also send out the array and have it as your only data copy. 🙂
/Y