Re:Coin Flip Brain Teaser
by dadkins on Friday July 24, 2009 @02:34PM
(#722104)
I decided to try to figure it out from this angle. What we have is a random walk where, with probability 0.51 we go forward, and with probability 0.49 we go backward. If we ever reach 10, we quit. I wrote a program to compute the cumulative probability that we stop at 10 over time.
The results:
You get to quit much sooner if you can walk away as soon as you have $10!
[ Parent
| on HN ]
The following lisp simulation gets numbers on about the same order of magnitude:
(defun flip () (if (< (random 100) 49) nil t))
(defun game (n d)
(declare (optimize speed))
(if (>= d 10) n
(if (flip)
(game (incf n) (incf d))
(game (incf n) (decf d)))))
(print (nth 1000 (sort (loop for i from 1 to 100000
collect (game 0 0)) #'> )))
Re:Coin Flip Brain Teaser
by madcaptenor on Friday July 24, 2009 @05:44PM
(#722492)
Somehow I wasn't seeing the exact formulas, even though I simulated it and got a similar answer.