03-23-2006 09:17 AM
03-23-2006 09:35 AM
I'm sorry that I can't answer you off "the top of my head", but it seems that you have defined your question in a way where it should be easy for you or someone to make up an example of each and benchmark them. I would, but am up to my eyes at the moment. Who ever does would help the community by posting the results.
P.M.
03-23-2006 09:37 AM
03-23-2006 09:56 AM - edited 03-23-2006 09:56 AM
Here's how I would do it:
It's pretty fast with a 100,000 element array, I'm guessing because of the pre-sizing of the array before the loop. Also, note the To I32 conversion bullet...this is required because of a "feature" of the Add Array Elements function that matches the output datatype to the input datatype...since the Boolean To (0,1) function generates an array of I16s, the Add Array Elements function will return a datatype of I16, even though there's a good chance that the sum of a bunch of I16s will be greater than 32767. Anyway, other than that little trick, everything else is pretty straightforward. It's handy that the In Range and Coerce function will take an array of numerics as an input.
Hope this helps,
-D
Message Edited by Darren on 03-23-200609:56 AM
03-23-2006 10:32 AM
Just a quick comment on a question you didn't ask...
I've often preferred to use deviation from Median value rather than deviation from Mean. Most any time I've wanted to summarize real-world data as an average, the median has done just as good at identifying the middle of a well-behaved clump of data. Where it really shines is in weeding out major outliers and short transient glitches. Those things can shift a mean noticeably away from the middle of the main clump, but tend to have almost no effect on a median.
Note that computing a median is likely more cpu-intensive than a mean. Here are code challenge results to give you an idea of computation time.
-Kevin P.
03-23-2006 11:14 AM - edited 03-23-2006 11:14 AM
Message Edited by kehander on 03-23-200611:17 AM
03-23-2006 11:20 AM
I think your second approach would be faster because doing In Range in a loop would be much faster than Search 1D Array in a loop.
-D
03-23-2006 12:44 PM
03-23-2006 01:11 PM - edited 03-23-2006 01:11 PM
The attached example (LabVIEW 7.1) shows one possibility. If you check array buffer allocations, there is exactly one (!) in the small data generation loop and nowhere else. 😄
Message Edited by altenbach on 03-23-200611:12 AM