Repeat something 100 times

Hi All - help please! How do I repeat the dice rolling (and recording results) in screen 2 of this activity 100 times with a single click?


I do not think this is possible to achieve with a single click. I say this because the only way for it to automatically log the values is using “history” which creates a list from the “capture” sink. However, the capture sink only captures values when you click the button.

I tried to create a simulator that would run 100 trials in 10 seconds and attach it to the “timeSincePress” source. However, although it creates 100 trials… it cannot record them.

I could be wrong… either way here is the work I started.

That’s correct if you are trying to generate the same number 100 times but it is possible to achieve the same result by generating 100 individual random numbers on button press. There are probably some fancy calculations you can do to achieve similar results with less random numbers but there’s a balance between performance and elegance there. Either way, 100 random numbers sounds like a beast.

Thanks both PanettaMath and Jay - amazingly quick responses (as ever from this community!).

One trial here generates a random number for each of 4 dice and count how many 3’s you get on the 4 dice. Each student can repeat this 30 times and record their results in the table. I then use aggregate which, as a class, will give us an experiment with roughly 750 trials. The idea here is to demonstrate how experimental probability will approach theoretical probability with an ever larger number of trials.

Ideally then, I want to run the highest possible number of trials with a single click (limited I think by a maximum list length of 10,000). This sounds possible in theory, but generating what might actually by 40,000 random numbers does not sound efficient…?

More efficient would be to generate the 4 numbers, process them to count how many 3’s we got and repeat to keep a running count of how many times we got 0, 1, 2, 3 or 4 threes from the four dice.

Either way, I don’t really know how to do it!

Interested in any suggestions thanks…

Hi Vince,

Thanks for that. I’ve been having a look at Chance Experiments • Activity Builder by Desmos.

Within the ‘game1graph3’ graph on screen 4 there’s some code which seems to stagger the start of each of 36 spinners using timeSincepress. It then processes and keeps a list to count how many times the player won out of 36.

It seems like it should help but I can’t quite figure it out!


Hey Richard,

This activity is setup differently than the previous activity you shared. The author created 36 separate random number generators in the script. So it is just as Jay said, it would be possible to record 100 trials from a single button press if you copy and paste 100 different randomgenerators (1,6) and then capture the results.

If there is something you have already started, I wouldn’t mind taking a look.

So, I would like to take this activity further. I want to take the two spinners at the end and basically create a slide where they run the spinners 36 times (no need to see the 72 spinners animations) and see the result in the table. How would you create these two CL (one for virtually spinning 36 times a spinner that has distribution 3/8 and 5/8) and then recording the result in the table ?

You could much more easily create a single list of numbers with a seed value from a button press.
In the CL:

number(`s_{eed}`): button.pressCount

In the graph:


Sometimes it’s easier to do calculations with a list, but if you absolutely needed separate variables, you could do that in the graph instead of the CL: