Thus, you have thousands of values along the X axis and you want to "convert" them to a much smaller range, hundreds, along the Y axis. Obviously, you can divide by 10 or get a module, but you also want to distribute them as much as possible homogeneous in the target range.
I think you need a compression function.
You can, for example, apply a sine function to an input and multiply by the size of the hash table. What value should the period have? It depends: the closer you expect the input values, the higher the period (so two close values will give two very different results). And vice versa: if the input values are not expected very close, a short period may occur.
private int hashCode(int input, int tableSize) { return (int)(tableSize*Math.sin(PERIOD*input)); }
source share