vendredi 12 juillet 2019

I need to find the nearest minor value in an array and get the index of it

I have a variable size array that is filled with probability values. For example: [0.00 0.469 0.3206 0.2099]

So I pick a number between (0,1] and I need to know the nearest minor number in the array and get the index of it.

ARray being [0 0.469 0.3206 0.209] Randomly choosen number: 0.418 So I expect the output being 2 (the index of the nearest minor value) but I keep getting 1 as output.




Aucun commentaire:

Enregistrer un commentaire