I need to make a coin flip that obeys a certain probability of outcome. For example, a coin flip with a 67% chance of coming out Heads, 83% chance of coming out Tails, etc.
I managed to get the result I'm after by populating an array with 100 true
and false
in the equivalent distribution, then picking one item at random. What is a more elegant way to go about it?
Random#rand(max)
(andKernel#rand(max)
):So:
In theory such can be "exact" like an array distribution method.