How can I get weighted random selections from an array in Perl?
- by Chaggster
I need to random some elements from an array. I'm doing that by randomizing the index $array[int(rand(100))]. I want some of the elements to appear more often. How do I do it?
I thought of a stupid solution of having those elements duplicated several times in the array, but I'm sure you guys can do better.