Week 5: Text 2
If I have 2 normal dice and throw them together to get a combined score, what proportion of the scores will be 2(double 1), 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12 (double 6)?
Which is the most common total for the dice pair?2018-02 – Maths Challenge
Write a program to calculate the probablility of getting a combined score of 7 when throwing two normal six sided dice.
Se ho 2 dadi comuni e li lancio insieme per avere un punteggio cumulato, quale percentuale dei risultati sarà 2, 3, …, 12?
Qual è il totale più frequente per una coppia di dadi?
Scrivi un programma per calcolare la probabilità di ottenere 7 come punteggio combinato lanciando 2 dadi.
Soluzione 1
Lancia i 2 dadi 10.000 volte conteggiando le uscite del 7.
Visualizza il conteggio trasformato in frequenza relativa.
CONTA=0
For i=1 To 10000
dado1=Math.GetRandomNumber(6)
dado2=Math.GetRandomNumber(6)
dadi =dado1+dado2
If(dadi = 7) Then
CONTA=CONTA+1
EndIf
EndFor
perc=CONTA/10000
TextWindow.WriteLine(perc)
Soluzione 2
Lancia i 2 dadi 10.000 volte conteggiando le uscite da 2 a 12.
Visualizza i conteggi trasformati in frequenze relative.
For i=2 To 12 CONTA[i]=0 EndFor For i=1 To 10000 dado1=Math.GetRandomNumber(6) dado2=Math.GetRandomNumber(6) dadi =dado1+dado2 CONTA[dadi]=CONTA[dadi]+1 EndFor For i=2 To 12 perc=CONTA[i]/10000 TextWindow.WriteLine(i + ": " + perc) EndFor
Soluzione 3
Lanciando i dadi 10, 100, 1000, 10000 volte si osserva come le frequenze relative tendono alle probabilità teoriche

NUM[1]= 10
NUM[2]= 100
NUM[3]= 1000
NUM[4]=10000
For esp=1 To 4
For lancio=1 To NUM[esp]
dado1=Math.GetRandomNumber(6)
dado2=Math.GetRandomNumber(6)
dadi =dado1+dado2
CONTA[esp][dadi]=CONTA[esp][dadi]+1
EndFor
EndFor
For X=2 To 12
TextWindow.Write(X)
For esp=1 To 4
perc=CONTA[esp][X]/NUM[esp]
TextWindow.CursorLeft=8*esp
TextWindow.Write(perc)
EndFor
TextWindow.WriteLine("")
EndFor
TextWindow.WriteLine("")