Random probability

Hi guys,
I was searching on the forum, but could not find a solution…
I need help with such a thing:
Let’s assume that we have three items on the list, and we want to draw them, so that each of them has a different probability of being drawn.
1 item = 60%
2 item = 30%
3 item = 10%
Is it possible to program this probability?
kind regards

Make a List of 10 items with -
item A 6 times - 60% chance
item B 3 times - 30% chance
item C 1 time - 10% chance

Then use pick a random item from list.

Surely and Shortly someone will Provide you a Better Answer. :sweat_smile:


I think your answer is better :yum:

Thank you very much ADDYLIN.
Your advice is indeed very simple and effective! :smile:
It works perfectly when lists are short and static!

However, if my initial list was much longer… then a list with repetitions would take up a lot of space :frowning:

I thought that maybe it can be done with some kind of mathematical function…

1 Like

Try this:


… or this:


Thank you very much bodymindpower!

This is exactly what I meant :slight_smile:
I am glad that this problem can be solved in such a simple and elegant way!

Best regards!

1 Like

Even shorter:


After 10 min of HardKoding :hot_face:,
i came up with this -
[ this will work with any number of items (helpful in dynamic lists) with any defined probability. ]

it’s good if this (probabilities) sums up to 100. [ No Error in Procedure even if it’s Not Summing to 100 ]

blocks (5)


Yeah, that’s impressive! :exploding_head:

Thank you very much for this solution! :clap:t3:
Indeed, this code is suitable for many possible situations!
I am impressed!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.