Random numbers - dice throw

Hello,

First of all - I know generating random numbers is a big topic. I need to find a solution for a specific problem.
I have a tree with 10 branches. Each branch contains of 10 EQUAL numbers in range 1-10.
For example {5} (3;3;3…3) {6} (7;7;7…7).
I want to generate 10 (each branch length) random numbers have the same range (1-10) for each branch.

I used a loop for seed of random number and want to find a set of numbers that AVERAGES to a value for each branch. F.ex branch {5} average is 3. So for example combination of 1,5,2,4,3,3,4,2,5,1 would result in average 3 and be passed over, than loop jumps into next branch.

My problem is generating random numbers for low and high values - for example getting average of 1 would only happen if one would get (1,1,1,1,1,1,1,1,1,1) - so I added a factor that values that average as 1,5 would also be passed.

As far as I am concerned rolling 10 1s in a row has the same possibility as rolling any other combination, and yet - I can never get that result (despite thousands of iterations).

I tried using both grasshoppers native “random” and “dice” component that can be fount in heteroptera plug-in.

Do you guys have any advice for me on how to approach that one?
Thanks

Hi @rekoks,

Do you mean like this?

In order to find result for low/high sum values (sum = list_length * average_value) you have to adjust possible values that you can select from randomly. After selection of one value you have again to adjust possible values and so on.
Code is in C# component. If there is no solution, code will find closest one withe least difference.


RandomItems.gh (9.9 KB)

1 Like

Hello,

If I understand correctly you would need Billions of iterations to have a good chance of getting 10 1s.

Do anagrams count as different sequences? Ie do you want to retain both 1,2,1 and 1,1,2 ?

Do you need every possible solution? If not, how many would you like?

Hello,

This is exactly what i meant, althought I solved that problem using loop in gh, without c#. Thank you very much for your help!

Have a good one!