Post Reply 
(11C) Roll "Four" Dice at Random
10-15-2018, 06:33 PM
Post: #9
RE: (11C) Roll "Four" Dice at Random
(10-15-2018 04:29 PM)Albert Chan Wrote:  For 3 dice rolls, dice distribution = 80*4 + 136*5. 5/4 = 1.25 is unacceptably bad.

How did you come up with this distribution?

Because I get the following result:

>>> dice_dist(1000, 1)
{0: 167, 1: 167, 2: 166, 3: 167, 4: 167, 5: 166}

>>> dice_dist(1000, 2)
{0: 335, 1: 333, 2: 332, 3: 335, 4: 333, 5: 332}

>>> dice_dist(1000, 3)
{0: 503, 1: 501, 2: 496, 3: 503, 4: 501, 5: 496}

While this isn't an exact equal distribution I wouldn't say it's biased.

However when we roll more dice the imbalance increases:

>>> dice_dist(1000, 4)
{0: 671, 1: 669, 2: 664, 3: 671, 4: 669, 5: 656}

>>> dice_dist(1000, 5)
{0: 839, 1: 837, 2: 832, 3: 839, 4: 837, 5: 816}

>>> dice_dist(1000, 6)
{0: 1007, 1: 1005, 2: 1000, 3: 1007, 4: 1005, 5: 976}

This is not a big surprise. There are now gaps between consecutive numbers and thus some of the values aren't hit as last digit.

Thus as a rule of thumb we should use it only if \(6^k < n\).
Therefore \(6^3 = 216 < 1000\) is still okay while \(6^4 = 1296 > 1000\) starts getting problematic.

This is the Python function I used to calculate the distribution of the dice:
Code:
def base6(n, k):
    for i in range(k):
        n, d = divmod(n, 6)
        yield d

def dice_dist(n, k):
    dist = dict(zip(range(6), [0] * 6))
    for i in range(n):
        roll = 6 ** k * i / n
        for d in base6(roll, k):
            dist[d] += 1
    return dist

Quote:To produce unbiased multiple dice roll, remove random below a threshold.
For my casio, remove RAN# below 0.136 should do it.

That means 0 (i.e. [1, 1, 1]) can never happen?
How is that not biased?

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) Roll "Four" Dice at Random - Gamo - 10-13-2018, 03:32 AM
RE: (11C) Roll "Four" Dice at Random - Thomas Klemm - 10-15-2018 06:33 PM



User(s) browsing this thread: 1 Guest(s)