LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

statistics over pairs of values

Solved!
Go to solution

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.

0 Kudos
Message 1 of 7
(1,547 Views)

Attaching sample data and any related VI will help us to play with our idea to solve your requirement.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 7
(1,521 Views)
Solution
Accepted by topic author blum22

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.

Spoiler
Statistics from XY Arrays.png

 

Redhawk
Test Engineer at Moog Inc.

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.

Message 3 of 7
(1,519 Views)

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.

0 Kudos
Message 4 of 7
(1,489 Views)

Thanks! That's indeed what I had in mind, but cleaner than how I would have done it.

Works great.

0 Kudos
Message 5 of 7
(1,479 Views)

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

0 Kudos
Message 6 of 7
(1,476 Views)

Here's how you could use a map.

 

altenbach_0-1661205396273.png

 

Message 7 of 7
(1,448 Views)