View Single Post
 Blog Entries: 8 Recognitions: Gold Member Science Advisor Staff Emeritus Firstly, my code written in Scheme: Code: (define (MakeRandomList) {local [(define (MakeRandomList-iter n) {local [(define x (+ (random 2) 1))] (if (= n 0) (list) (cons x (MakeRandomList-iter (- n 1))))})] (MakeRandomList-iter 10)}) (define (ListEqual List1 List2) {local [(define (ListEqual-iter l1 l2) (if (empty? l1) true (and (= (car l1) (car l2)) (ListEqual-iter (cdr l1) (cdr l2)))))] (ListEqual-iter List1 List2)}) (define list1 (list 1 1 1 1 1 1 1 1 1 1)) (define list2 (list 1 2 1 2 1 1 1 2 1 2)) (define (Test n) {local [(define (Test-iter n amount1 amount2) {local [(define CurrentList (MakeRandomList))] (if (> n 0) (if (ListEqual CurrentList list1) (Test-iter (- n 1) (+ amount1 1) amount2) (if (ListEqual CurrentList list2) (Test-iter (- n 1) amount1 (+ amount2 1)) (Test-iter (- n 1) amount1 amount2))) (list amount1 amount2))})] (Test-iter n 0 0)}) (Test 1000000) A disclaimer first: the original post worked with "rolling the dice 20 times". This is unfeasable. Therefore, I changed the problem to "flipping a coin 10 times". I worked with the two sequences 1111111111 and the supposedly random sequence 1212111212. Now, what I did was: Each test, I flip a coin 10 times. If the result is not one of the two sequences above, I discard the test. If the result is one of the two sequences above, I add 1 to the amount of times I saw the sequence. This I do a million times. Why is this a good representation of the test? The original test was that I flip a coin 10 times. Then I get a choice which one of the above sequences was rolled. Of course, to get that very choice, I actually need to get one of the sequences. This is why every experiment where I do NOT get one of the sequences, I discard it. After I got one of the sequences, I can choose which one of the sequences I get. Adding 1 to the amount of times I saw sequence 1 corresponds to getting it right if you guessed 1. Adding 1 to the amount of times I saw sequence 2 corresponds to getting it right if you guessed 2. Eventually, the two amounts correspond to the number of times you got it right. So, after iterating it a million times, I get Sequence 1: 948 Sequence 2: 995 A subsequent test yielded: Sequence 1: 1015 Sequence 2: 1001 These two are so close together that it seems plausible that the actual amount you get things right is indeed 50-50. Running it more than 1000000 times will only reinforce this, but I don't got the time to do so.