In the extremely advanced statistics paper I'm doing (STAT131), our lecturer mentioned something about consecutive heads (or tails) on a coin toss. Saying that the series T, HT, HHT, HHHT, ... is theoretically infinite. Which is true. But in practice your sequence of heads is going to be relatively short.
To prove this I wrote a little Java program that would calculate these chains using the built-in pseudorandom number generator. After I got this working, I ran it for an hour on one of the uni computers. For the 80 billion trials it did, the longest chain was only 36. That's pretty short really. (I don't think the non-randomness of the pseudorandom number generator would've had any significant effect). Evaluate 2^36 and you get 70 billion (to 1 significant figure), so this was basically as expected, a chain of length 36 is a one in 70 billion chance. That's a (relatively) huge number really.
Just for fun I reimplemented my program in C, which made it about 20% faster, which is about what I expected. (Actually, it was slower on a multicore computer as I multithreaded the Java version, but I don't know how to write threaded programs in C). Anyways, that was my interesting experiment for Tuesday (when I did it).
Friday, July 17, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment