I studied python programming on edX , which is a very good course, and I still fully recommend it. Just by looking at the TED talk in Statistics, I thought it was a great way to realize the python skills that I chose in a real-world scenario. The guy gave an example of the likelihood that he constantly flips the coin and searches for two repeating sequences, which, as he explained, you would consider the same probability as you claimed, in fact they do not. Simply put, he claims that Heads Tails Heads are more likely than Heads Tails Tails, because at the end of the first sequence you are already one third to repeat the sequence again, where at the end of the second sequence you then need to throw one more head to again start the sequence. This makes sense, so I tried to prove it with my little python program shown here.
import random
HTH = 0
HTT = 0
myList = []
i = 0
numberOfTosses = 1000000
while i < numberOfTosses:
myList.append(random.randint(0,1))
i += 1
for i in range (len(myList)):
if i+2 >= len(myList):
break
if myList[i] == 1 and myList[i+1] == 0 and myList[i+2] == 1:
HTH +=1
if myList[i] == 1 and myList[i+1] == 0 and myList[i+2] == 0:
HTT +=1
print 'HTT :' ,numberOfTosses, HTT, numberOfTosses/HTT
print 'HTH :' ,numberOfTosses, HTH, numberOfTosses/HTH
, , , , , HTH evey 8 tosses HTT- 10, . , : ?