I have N values ββ(integer). I would like to know what is the most elegant way to randomly select one of these values ββin terms of percentage. For example, for an example of 3 values:
- Value 1 has a 30% chance of getting the selected
- Value 2 has a 12% chance to get the selected
- Value 3 has a 45% chance of getting the selected
I need this for a program that I am developing using Java, but a pseudo-code algorithm or code in any other language will be fine.
source share