Finding the mode of a set of numbers

Hi everyone, I’ve got a set of numbers and i’m trying to find an algorithm that allows me to extract the mode (the number that appears more times in the set) from it, but i really can’t find a way.

And what if i want to add a tollerance to the algorithm? what i mean is:

in a set like:

1.00
2.00
2.00
2.00
2.10
3.01
3.04
4.95
5.00
5.00
5.01
5.02
5.09
6.01
7.00
7.50

The mode is 2.00 because that’s the most frequent value, but adding a sort of tollerance like 0,1 (e.g.) the mode changes to circa 5, bacause accepted values are 4.95, 5.00, 5.00, 5.01, 5.02, 5.09.

I know that this can be a difficult question, but there is someone of good will out there? Thanks a lot :slight_smile:

Hi @Marcuccio_90 ,
you could do something like this :

It’s not perfect though

I think he’s looking for the exact value. If that is the case, we can simplify Mostafa’s graph a bit:

1 Like

Thank you both. Your suggestions have been really useful :grin: