I'm trying to figure out how to best work a weighted probability model into code - I'm trying to implement a random selection where each element has their own separate probability of being chosen.
I am able to get each probability as a float, and the sum approximates 1.
What is the best way to emulate this sort of weighted probability?
(Sorry if this doesn't belong in the forum; I tried looking it up but didn't really know what I was doing.)
I considered doing that, but the number of elements is arbitrary, so wouldn't that end up being wasteful as I need more and more integers in order to accurately mimic the probabilities (as integer ranges)?