infundibulum

Heads and Tails

November 30th, 2006

Interesting talk on statistics (no, really) from TED:

TED Blog: Statistics

Peter Donnelly gives some evidence that people are bad at estimating probabilities. One example he gives is the following:

Given a fair coin, how many times do you need to flip the coin to produce the pattern HTH? How many times to produce HTT?

Seems like they should be equal, right?

They’re not.

from random import choice

"""
I watched this guy's talk:
http://tedblog.typepad.com/tedblog/statistics/index.html
And didn't believe him.
Now I believe him.
"""

def avg(seq): return float(sum(seq)) / len(seq)

def game(pattern):
"""count number of flips required to produce pattern"""
s = ''
i = 0
while not s.endswith(pattern):
i += 1
s += choice(['h', 't'])
return i

def tournament(pattern, numgames):
"""average many games"""
return pattern, avg([game(pattern) for i in range(numgames)])

for pattern in ['hth', 'htt']: print tournament(pattern, 100000)

Here’s the output:

$ python coins.py
('hth', 10.009219999999999)
('htt', 7.99892)

The explanation in the video is pretty good, but it still makes my eyes cross because for some reason I want ‘htt’ to be less common than ‘hth’, which is exactly wrong.

wtf?

November 30th, 2006

This is hilarious ☺

November 30th, 2006

Oh whatever.

November 23rd, 2006

Two columns of text is not for teh intartubes. No, rly.

November 22nd, 2006

Emily Oster on death, etc.

November 21st, 2006

Left Navigation Sidebars… endangered species?

November 14th, 2006

Things Lakota/Dakota/Sioux. And copyright.

November 14th, 2006

Ads in Bengali, Police work in Portuguese, and Medicine in Spanish

November 12th, 2006

Physics for President

November 9th, 2006