LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

big data for calculate mean, max,min

Solved!
Go to solution

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?1.png

0 Kudos
Message 1 of 11
(3,508 Views)

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

0 Kudos
Message 2 of 11
(3,490 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 11
(3,477 Views)

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.

0 Kudos
Message 4 of 11
(3,474 Views)

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.

0 Kudos
Message 5 of 11
(3,473 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 11
(3,465 Views)
Solution
Accepted by topic author Tarzan-Chan

There are also some point by point methods that can be used (search for example for "mean pt"). 

Certified LabVIEW Architect
0 Kudos
Message 7 of 11
(3,459 Views)

@thols MeanPtByPt has an internal array of 100 elements (per default), so it might be inaccurate if the array is large.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 8 of 11
(3,450 Views)

@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.

Certified LabVIEW Architect
0 Kudos
Message 9 of 11
(3,447 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 11
(3,438 Views)