LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

mode function in statistics

I have an array of intergers and I want to find the most commonly occurring element in the array. I thought this was the definition of Mode in statistics. however, the mode funciton returns a floating point value. If I have an array with 19 elements, 17 are 50 and two are 150, the mode funciton gives me 50.25 as the result. I would have expected the result to be 50. I don't mind writing my own funciton, but what is the native statistics function doing here?

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 1 of 7
(4,436 Views)

Hi sphaeroid,

 

usually you use a histogram function to detect (ranges of) the most common value(s) in your data…

 

Mind to attach a VI with default data (and expected result)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(4,430 Views)

Hi Gerd:

 

I gave my example already, didn't I. I'm asking about what mode means. I was taught it means most commonly occurring value value. It's a counting function. I see that it is not implemented this way in LabVIEW, but then I'm not clear on what LabVIEW's mode function is.

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 3 of 7
(4,416 Views)

Hi sphaeroid,

 

there is no example VI in your first post, just some words…

 

Did you read the help for the Mode function? It explains the behaviour in the "details" section!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(4,409 Views)

littlesphaeroid,

 

The Mode VI has an input called Intervals, which specifies the number of histograms it uses in the algorithm and then returns an estimated mode. If you want this function to return the exact mode, then set Intervals to 0. You should then see a result of 50 instead of 50.25 for example.

 

0 Kudos
Message 5 of 7
(4,381 Views)

Others have said it already, but here is the linked help on that function.

 

http://zone.ni.com/reference/en-XX/help/371361H-01/gmath/mode/

 

This help is instealled with LabVIEW.  Open the Context Help (CTRL+H) in LabVIEW and hover over this function.  In the help window there is a button for detailed help that has this same information.

0 Kudos
Message 6 of 7
(4,374 Views)

Thank you elcalverado! This makes sense and now I understand. I was not aware that mode could mean anything else! Your response was helpful.

 

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 7 of 7
(4,345 Views)