I'm not very good at math but I need to know how to get a set of numbers that are closest to each other.
It means that if I have 5 numbers
[-1, 2, 7, 11, 3222]. Now it is obvious (to me) without any rules to see that correct numbers would be
-1, 2, 7, 11 or even
-1, 2, 7. However I have no idea how to implement some kind of rule that will allow programatically filter a set of numbers and get viable ones.
You can clearly see that simple solutions like calculating median from all numbers and then getting closest numbers to it would be wrong.
Maybe if I would take median of all numbers except
3222, calculate median, get all numbers from set that are +10/-10 it would work well, however, how do I make computer know that
3222 does not belong here...
So basically I'm pretty stuck here. As I said I'm not very good with math so don't judge me by asking this silly question.