08-22-2022 02:58 PM
Hello community,
I am working on pairs of values generated by some data analysis. They come in two 1D-arrays of equal sizes (typically thousands of values) that I then cluster to plot in an XY graph, much like described here.
However, my analysis is such that I can get a lot of pairs for a given X-value, and my X-values are integers. Therefore, I would like to perform some basic statistics on each set of XY-pairs for a given X (number of pairs, mean, median,...), but I don't see any obvious way of doing that the way my pairs are currently organized.
Am I missing something here, or do I have to sort all my pairs by X-values?
The screenshot is an example of my XY graph.
Solved! Go to Solution.
08-22-2022 03:35 PM
Attaching sample data and any related VI will help us to play with our idea to solve your requirement.
08-22-2022 03:40 PM - edited 08-22-2022 03:43 PM
It seems to me that yes, you would have to separate your Y values into subarrays of Ys that are associated with each X. See if this skeleton code helps at all.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
08-22-2022 04:08 PM
It would help to see some typical data. For example are the pairs already sorted by X or not?
I would use a map with x as key and an array of Ys as values. Once the map contains all data, iterate over all keys and do the statistics on the y (array size (=# of parts, mean, etc.)
@blum22 wrote:
... perform some basic statistics on each set of XY-pairs for a given X (number of pairs, mean, median,...),
Can you give a complete list of the needed statistics? Some can be done ptbypt, some not.
08-22-2022 04:11 PM
Thanks! That's indeed what I had in mind, but cleaner than how I would have done it.
Works great.
08-22-2022 04:16 PM
Thanks a lot for your feedback. No, the pairs aren't sorted as they are generated without clear order, but I will keep maps in my mind for future use (I didn't know they were introduced in LabVIEW).
08-22-2022 04:57 PM