How to create a random C function with weighted variables
How to create a random C function with weighted variables
(OP)
Does anyone know of a C random function that allows for weighted variables? For example...
I would like to assign variable a random value between 1 and 5. However, I would like for this value to be certain numbers more frequently than others. So I would like to be able to use a function that will randomly select the value 1 - 20% of the time, 2 - 25% of the time, 3 - 30% of the time, and so on.
I would like to assign variable a random value between 1 and 5. However, I would like for this value to be certain numbers more frequently than others. So I would like to be able to use a function that will randomly select the value 1 - 20% of the time, 2 - 25% of the time, 3 - 30% of the time, and so on.





RE: How to create a random C function with weighted variables
To randomly select an integer between 1 and 5, but with biased output, you use the same rng, but you divide the number line unevenly.
That's one way.
Mike Halloran
NOT speaking for
DeAngelo Marine Exhaust Inc.
Ft. Lauderdale, FL, USA