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
SaneFungus
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.
I think your answer is better
Thank you very much ADDYLIN.
Your advice is indeed very simple and effective!
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
I thought that maybe it can be done with some kind of mathematical function…
Thank you very much bodymindpower!
This is exactly what I meant
I am glad that this problem can be solved in such a simple and elegant way!
Best regards!
After 10 min of HardKoding ,
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 ]
Yeah, that’s impressive!
Thank you very much for this solution!
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.