Post Reply 
Casio calculator and Roll Two Dice in Random
08-22-2020, 01:25 AM
Post: #4
RE: Casio calculator and Roll Two Dice in Random
(08-21-2020 11:53 AM)Albert Chan Wrote:  Method 1: treat each digits as a throw, but eliminate bad cases (outside 1 to 6)

RAN#: 0.846 0.479 0.035                        -> dice throws = 4 6 4 3 5       // eliminated 4 throws out of 9

I was curious, on average, how many RAN# do we need to get 2 valid dices ?

Let p = probability of valid digits = 6/10 ; bad cases q = 1-p = 4/10

Probability distrubution = (p+q)³ = p³ + 3p²q + 3pq² + q³ = 0.216 + 0.432 + 0.288 + 0.064 = 1

Let a = 0.216 + 0.432 = 0.648       // 2+ valid dice from RAN#
Let b = 0.288                                // 1 valid dice from RAN#
Let c = 0.064                                // 0 valid dice from RAN#

Let Rk = probability of finally getting 2+ valid dices for k-th RAN#

R1 = a
R2 = c·a + b·(1-c)
R3 = c²a + 2bc·(1-c)
R4 = c³a + 3bc²·(1-c)
...

Expected RAN#'s to get 2+ valid dices
= [R1,R2,R3,R4, ...] • [1,2,3,4, ...]
= a*(1 + 2c + 3c² + 4c³ + ...) + 2b*(1-c)*(1*2/2 + 2*3/2*c + 3*4/2*c² + ...)
= (a + 2b) / (1-c)²                        // see thread, Cut the Cards
1.39711

This matched simulation result Smile
Code:
function test(n)
    local t = 0
    for i=1,n do
        local d = 0
        repeat
            t = t + 1       -- throws            
            if random(10) <= 6 then d=d+1 end
            if random(10) <= 6 then d=d+1 end
            if random(10) <= 6 then d=d+1 end
        until d >= 2        -- 2+ valid dices
    end
    return t/n
end

lua> test(1e7), test(1e7), test(1e7), test(1e7), test(1e7)
1.3970112       1.397293       1.3971118       1.3968499       1.3971645
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Casio calculator and Roll Two Dice in Random - Albert Chan - 08-22-2020 01:25 AM



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