Active Forums => Programs => Topic started by: Qwerkey on November 24, 2021, 12:41:38 pm
Title: Maximum Consecutive Same Heads/Tails in Coin Toss
Post by: Qwerkey on November 24, 2021, 12:41:38 pm
When I created my coin toss graphics program https://www.qb64.org/forum/index.php?topic=4117.msg134684#msg134684 (https://www.qb64.org/forum/index.php?topic=4117.msg134684#msg134684) as a check that it was working correctly, there must not have been many consecutive same heads or tails (the program did seem OK in this respect).
But I wondered if you let QB64 run continuously with a 50/50 random, what would the maximum same consecutive be. [Theoretically (?) if you do 50/50 for an infinite time you'd get a sequence sometime of infinite consecutive same].
The program runs freely and occasionally prints the maximum number of same consecutive "heads or tails". On my laptop this number is 24, seemingly never exceeded. The likelihood of getting 24 same consecutive heads or tails is low (~ 1 in 16 million, but the program is doing billions of cycles). Occasionally, one might expect the maximum of 24 to be exceeded.
I think that I must be doing something stupid with the code.
Title: Re: Maximum Consecutive Same Heads/Tails in Coin Toss
Post by: bplus on November 24, 2021, 02:44:01 pm
Wasting polls usually made it worse but I got it to do 26 with this (2 wasted polls):