i’m developing an implementation of ant colony algorithm, and stuck at find nearest value process. here is the problem.
i have an array contains cummulative probabilities, let say: cummulativeProb:{0.0, 0.34782608695652173, 0.8695652173913044, 1.0}
and there is a random number: randomNumber: 0,3323792320
i want application choose nearest value from randomNumber, but NOT bigger than randomNumber, that means application will choose 0.34782608695652173
can you give me a hint, please?
Look at Arrays.binarySearch() this will give you the element that equals what you are looking for, or -ve the index that is lower than what you are looking for.