Given a set of numbers such as this:
1, 1, 1, 1, 1, 5, 10, 10, 10, 20, 20, 20, 20
The numbers in the set are "magnetized/weighted" (sorry for lack of better term). Given an input number, it should always output a number that already exists in the set - with a higher likelihood of being output as that number based on frequency in the set (lots of 1's in above example), and how close the input is to it.
Example input/outputs:
- 6 -> 5
- 7.5 -> 10
- 15 -> 20
- 2 -> 1
Does anyone know what this type of problem is called? Or how I could develop a formula for it? I've been trying to search for it, but haven't had any luck finding what this type of problem is.