An Unintuitive Coin Flip Problem (With Secret Markov Chains)

Professor Peter
Professor Peter
10.8 هزار بار بازدید - 4 سال پیش - Here's a seemingly easy coin
Here's a seemingly easy coin flip probability question that might have you reconsidering what you know about probabilities. Under the surface of this short problem is a probability phenomena known as a Markov Chain. In this video we'll introduce the problem, try to simulate it using some python code, and then explain why the results we're seeing seem to contradict what we know about probability and coin flips.

---------------
I tweet math things on Twitter: Twitter: MathProfPeter
I stream math things on Twitch: Twitch: ProfessorPeter

---------------

Python code (in case you want to try it yourself):

import random

###################################
Setup
###################################

population = [0,1] # 0 = H, 1 = T
pattern1 = [0,0,1] # HHT
pattern2 = [0,1,1] # HTT
trials = 1000000 # a million trials!
p1wins = 0
p2wins = 0

###################################
Flip the coins and check the patterns we see
###################################

for x in range(0,trials):
 fliplist = []
 while fliplist != pattern1 and fliplist != pattern2:
    Flip a coin, add it to the list, check against the patterns
    flip = random.choice(population)
    fliplist.append(flip)
    fliplist = fliplist[-3:] # only keep the latest 3 flips
 if fliplist == pattern1:
   p1wins = p1wins + 1
 if fliplist == pattern2:
   p2wins = p2wins + 1

###################################
Summary information
###################################

p1percent = round(float(p1wins)/trials * 100,2)
p2percent = round(float(p2wins)/trials * 100,2)

print "Pattern 1 (HHT) won", p1wins, "times. This is ", p1percent, "%"
print "Pattern 2 (HTT) won", p2wins, "times. This is ", p2percent, "%"
4 سال پیش در تاریخ 1399/03/03 منتشر شده است.
10,862 بـار بازدید شده
... بیشتر