I did research and found the algorithm for small lists in general. I have some arrays such:
arr = [1,2,3,4 .... , 96,97,98,99,100];
arr2 = [105, 110, 165, 170];
arr3 = [1,2,7,8,9];
I want to send these arrays to a function and get random numbers from this array, but I want to have a higher probability of getting bigger numbers every time.
For example in array 1, the probability of 96 should be more than 4, but the probability of 97 should be more than 96.
How to generate a random weighted distribution of elements
Usually the solutions are like in this topic. However, this can cause performance problems with my arrays.
How can I achieve that?
Aucun commentaire:
Enregistrer un commentaire