09-05-2018, 09:05 PM
(This post was last modified: 09-05-2018, 09:07 PM by sirpipthegreat.)
Thanks for your response! I didn't even think about IStringMap. That will be super helpful in for holding the array dictionary.
The end result was to have it only return one value.
I was giving an example of how often the result would appear with the 1/40. (2.5%) but wanted it to be dynamic so that if you added grapes to the list with a weight of 100, pear would go down to 1/140 (~0.7%)
I think you're onto something with summing them up. I'm just not sure how to do a RandomInt of the sum and get them to cooperate with their weights.
The super inefficient way would be to populate an array with each item a number of times equal to their weight, then pull a random line. That would make sure that pears would only be in the list once, apples would be in there nine times, and so on... so there would be a higher chance for RandomInt to pick apples than pears.
in python it would be:
random.choices([apple,pear,banana,orange],[9,1,10,20])
I was hoping to be able to recreate this function in QM.
The end result was to have it only return one value.
I was giving an example of how often the result would appear with the 1/40. (2.5%) but wanted it to be dynamic so that if you added grapes to the list with a weight of 100, pear would go down to 1/140 (~0.7%)
I think you're onto something with summing them up. I'm just not sure how to do a RandomInt of the sum and get them to cooperate with their weights.
The super inefficient way would be to populate an array with each item a number of times equal to their weight, then pull a random line. That would make sure that pears would only be in the list once, apples would be in there nine times, and so on... so there would be a higher chance for RandomInt to pick apples than pears.
in python it would be:
random.choices([apple,pear,banana,orange],[9,1,10,20])
I was hoping to be able to recreate this function in QM.