Hi all,

I would be glad if somebody could explain to me why the following function 
which generates a pair of random integer between 1 and 6 and if they are 
equal generates another pair

function fun()
    d, N = 6, 50
    for n = 1:N
        a, b = rand(1:d), rand(1:d)
        if a == b
            c, d = rand(1:d), rand(1:d)
            println("$a, $b, $c, $d")
        end
    end
end


under Windows 7 64 bits and Julia 0.4.1 returns mostly 1s.

julia> fun()
1, 1, 3, 3
3, 3, 3, 2
2, 2, 2, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1
1, 1, 1, 1

For small N, the output is more random though.

Thank you,
michele

Reply via email to