A small Ruby script to test Peter Donnelly’s example on uncertainity. Conference below..
def avg_pat(pat, t, s=0) t.times do last = '' last += (rand(2)==0 ? 'H' : 'T') while last[-pat.length..-1] != pat s += last.length end s/t end ['HTH','HTT'].each{|p| print "#{p} #{avg_pat(p,10000)} "}