Sunday, May 29, 2011

R matey!

Tony (my R matey) has written a simulation (in R of course) of my card trick from the other day. Go to his post for more detail, but here are some plots:

Pretty neat! You can see that starting from 10 different initial numbers, we quickly converge to just a few paths, and ultimately to the same path. However note that it sometimes takes longer than 1 deck of cards for complete convergence. For this reason, I often do this trick with two decks combined if I can.

But even if not, the odds are pretty decent that I'll guess the right card. On the one hand, you might think that when there are 2 paths remaining, I'm equally likely to be in the correct path as the incorrect path. Well, it's true that on average there are 5 initial numbers leading to each of these two paths, and I'm equally likely to have been in one set as the other set. But actually, whenever it's not split 5-and-5 I have a distinct advantage, because the goal is merely to be in the same path as the other person, and we're both more likely to be in the more likely path. For instance, if it happens that 8 initial numbers lead to 1 path and 2 numbers lead to the other, then the probability that we're in the same path is .8*.8+.2*.2=.68, much better than .5!

Speaking of R, you may enjoy this video of a horse named ARRRRR:


  1. Exogen(e)ous CombustionMay 29, 2011 at 8:49 PM

    I have been waiting with bated breath for a graphic like that (and was hoping for one about the card trick). Fun to see.

    Tony's graph illustrated that perfectly, kudos to you both.

  2. EC,

    By the way don't you think it's about time you changed your blog to "A Graph a Day"?

    If you ever feel compelled to make a graph for one of my posts, I will feature it gladly!