I have an array with some numbers
[0, 0.1, 0.2, 0.3, 0.6, 0.8, 1]
how do I remove numbers that are close to each other less than or equal to 0.2
threshold and put the average of those values instead,
so the above array becomes
[0.2, 0.8]
0.2
because [0, 0.1, 0.2, 0.3]
are close to each other so they become (0 + 0.1 + 0.2 + 0.3) / 4 = 0.2
0.8
because [0.6, 0.8, 1]
are close to each other so they become (0.6, 0.8, 1) / 2 = 0.8