Zelandakh, on 2016-April-17, 11:46, said:
Well, I don't know how general you mean the general case to be, but I think it is quite clear that you cannot accurately simulate throwing two 2-sided dice by throwing three 2-sided dice.
Posted 2016-April-17, 15:26
Zelandakh, on 2016-April-17, 11:46, said:
Posted 2016-April-17, 20:41
mgoetze, on 2016-April-17, 15:26, said:
HHHT -> HH HTTT -> TT HHHH + TTTT + HHTT -> HT
Posted 2016-April-18, 02:39
Posted 2016-April-18, 05:58
Cyberyeti, on 2016-April-18, 05:04, said:
Posted 2016-April-18, 22:37
When m = 3 and n = 2: t = m1 + m2 + m3. n1 = 1 + (t mod 6). n2 = 1 + (t mod 3) + 3 * (t mod 2).
Posted 2016-April-19, 00:08
Posted 2016-April-19, 06:51
Posted 2016-May-26, 05:41
nige1, on 2016-May-25, 23:39, said:
Posted 2016-June-05, 19:02
<!DOCTYPE html> <html> <head> <title>dice</title> <meta name="author" content="2016 Nigel Guthrie"> <meta charset="utf-8"> <style> nav { background: yellow; position: fixed; right: 0; top: 0; width: 15em; z-index: 1; }/* Right menu sidebar */ .D { text-align: right; border: medium solid black; } .D0, .D1, .D2 { background: red; color: white; font-weight: bold; text-align: center; } .D0 {background: green;} .D2 {background: blue;} </style> </head> <body> <nav> <p>Numberphile 3 dice ==> 2. <br>Click a transform method</p> <ul> <li><a href="javascript: DEMO.show (modmod);">modmod: Modulo 6 and 3.</a> <li><a href="javascript: DEMO.show (tetris);">tetris: Tetra/tri nums.</a> <li><a href="javascript: DEMO.show (bigwee);">bigwee: Big and small.</a> </ul> </nav> <script> const SIDES = 6; var DEMO = { a: SIDES, b: SIDES, c: SIDES, start: function start () { DEMO.a = DEMO.b = DEMO.c = 6 },// initialize demo. die: function die () { return 1 + Math.floor (SIDES * Math.random()) },// Random die throw. rand3: function rand3 () { return [DEMO.die(), DEMO.die(), DEMO.die()] },// Random throw of 3 dice. perm3: function perm3 () { if (++DEMO.c > SIDES) { DEMO.c = 1; if (++DEMO.b > SIDES) { DEMO.b = 1; if (++DEMO.a > SIDES) { DEMO.a = 1; } } } return [DEMO.a, DEMO.b, DEMO.c]; },// Next higher permutation of 3 dice. sumMod: function sumMod(d, m) { return (d[0] + d[1] + d[2]) % m },// Sum of dice modulo 3. tri: function tri (n){ return n * (n + 1) / 2 },// Triangular number. tet: function tet (n){ return n * (n + 1) * (n + 2) / 6 },// Tetrahedral number. show: function show (dice3) { h2 = document.createElement ("h2"); document.body.appendChild (h2); h2.innerHTML = ("Demo of method: " + dice3.name); DEMO.simulate (DEMO.perm3, dice3, 216); DEMO.simulate (DEMO.rand3, dice3, 3600); },// Create table, demonstrate method with permed and random throws. simulate: function simulate (dice3, transform, chucks) { var m = DEMO.table (dice3.name); for (var i = 0; i < chucks; i++) { var d3 = dice3 (); var d = transform (d3); m [d[0]][d[1]].innerHTML++; m [d[0]][SIDES + 1].innerHTML++; m [SIDES + 1][d[1]].innerHTML++; m [SIDES + 1][SIDES + 1].innerHTML++; // alert ("3 dice: " + d3 + " ==> 2 dice: " + d); } },// Count occurences of each pair of dice. table: function table (text) { var m = []; var tb = document.createElement ("table") document.body.appendChild (tb); for (var r = 0; r < SIDES + 2; r++) { var tr = document.createElement ("tr"); tb.appendChild (tr); m [r] = []; for (var c = 0; c < SIDES + 2; c++) { var td = document.createElement ("td"); td.className = "D"; tr.appendChild (td); m [r] [c] = td; } m [r][0].innerHTML = m [0][r].innerHTML = r; m [r][0].className = "D1"; m [0][r].className = "D2"; } m [0][0].innerHTML= text; m [0][0].className= "D0"; m [0][SIDES + 1].innerHTML= m [SIDES + 1][0].innerHTML= "Total"; return m; }, };// Demo object containing common functions. function modmod (d) { /** Promising but failing effort. Sum mod 3 is the index of the 2nd die. **/ return [ 1 + DEMO.sumMod (d, 6), d.sort () [DEMO.sumMod (d, 3)]]; };// 3 dice => 2. Choose a die depending on sum mod 3 (fails). function num35 (a, b, c){ if ((a == b) && (b == c)) return 0; if (b == c) b = a; return DEMO.tet (5 - a) + DEMO.tri (5 - b) + 5 - c + 2; };// Jan van Lent: 3 dice ==> number from 0 to 35 (uniformly). function tetris (d) { /** Jan van Lent's solution. Reduce 3 dice to a number from 0 to 35. The two dice are n mod 6 and the floor of n/6. **/ d.sort (); var n = num35 (d [0], d [1], d [2]); return [1 + Math.floor (n/6), 1 + n % 6] }; function bigwee (d) { /** Gwnn's solution. Define s as 1, 2, 3, or 4 and B as 5 or 6. identical numbers: 66 BBB: 55 (nb: just 556 or 566 as 555 and 666 are already taken) ssB: ss (i.e., forget about the 5 or 6) sBB: s5 (i.e., take the small one and include a 5) sss: m6, where m is the sum of the three mod 5. **/ d.sort (); if ((d[0] == d[1]) && (d [1] == d[2])) return [6, 6]; if ((d[0] > 4) && (d[1] > 4) && (d[2] > 4)) return [5, 5]; if ((d[0] < 5) && (d[1] < 5) && (d[2] > 4)) return [d[0], d[1]]; if ((d[0] < 5) && (d[1] > 4) && (d[2] > 4)) return [d[0],5]; return [1 + DEMO.sumMod (d, 5), 6]; } </script> </body> </html>
Posted 2016-June-06, 09:36
Posted 2016-June-06, 09:38