Weighted random numbers

riotchild's icon

Hi everyone, I’m looking for a way to ‘randomly‘ select from a set of numbers ranging from 1 to 10 inclusive, where each number has an associated weighting value from 1 to 100 inclusive.

e.g.
1, 23;
2, 56;
3, 89:
etc

The ‘random‘ selection of a 1-10 value needs to be influenced by the weighting value where the higher the value, the more likely the number is chosen. In the above simple data set, 3 would be chosen most often (ideally 89% of the time), 2 next most often, then 1.

Thanks in advance.

double_UG's icon

[itable]

Max Patch
Copy patch and select New From Clipboard in Max.

riotchild's icon

Brilliant, thanks. I can't find any mention of this feature in the documentation for this object.