Geek night

Geek night

GM smurfo
May 22, 2014, 3:35 PM |

Today was a good day. The sun was not only shining but actually warm, which is a rarity for the solar mass that usually takes an aesthetic-only approach to the Amsterdam sky. In fact, shorts and flip-flops were the order of the day, for the first time in the Netherlands since, well, about a year. More importantly from my perspective, however, I could actually ride around and enjoy the rare good weather. Today was the first day in a fortnight I've gone without a crutch, after a nasty ankle injury at touch football a fortnight ago. For the ignorant, touch football is the non-violent version of rugby union - basically, the form of the game that is supposed to prevent injury. Oh, the irony.

A fat ankle, pictured next to another injured patient

Anyway, that's not the point of the story, although it does explain why I decided to take the afternoon off and go cycling around the nearby forest. I sat on the grass soaking up pretty much Amsterdam's yearly quota of rays while practising some card tricks. Say what now? I may not have mentioned this before, but one of my 2014 New Years resolutions was to learn some amateur magic. Readers will know how seriously I take my resolutions - for example, see herehere and here. I've always been fascinated with magic, but I should mention that I have absolutely no idea what I'm doing, having never so much as attempted to guess a card before a couple of months ago. Nevertheless, in what will no doubt prove to be an incredibly stupid move, I'm signed up to perform at the annual Tinbergen Institute variety show next week. What could go wrong?

This, also, is not the point. But we're getting there. As part of my 'magic research', I stumbled on a fantastic little YouTube channel called 'Scam School'. As the name suggests, it's made up of a bunch of videos about how to play little tricks on people, "at the bar or on the street", all ostensibly in order to meet people and score free beer. Well, you can check it out for yourselves, but it is pretty cool, I have to admit. But then I came across the following sneaky little card trick, apparently based on probability theory...  

Basically, the idea is that you flip over a deck of cards one at a time, each time asking your victim to guess the value of the face. If they get it wrong - a one-in-thirteen chance - they get to move on to the next card; if they get it right and hit a match, they lose. The video suggests you can give them pretty good odds (in the video, they give odds of "$30 if you win, a beer if I win") and still be confident of winning. The reason for this, as any mathematician will smugly inform you, is that this 'one in thirteen' probability multiplies, so that the chances of your victim not getting a match if they randomly call out cards is (1/13)^52, or roughly 1.6%. Over 98% of the time, you'll win a beer! But then, tonight, I got to thinking: just guessing random cards isn't a very good strategy at all. At the very least, our poor sucker should name the card that got shown on the last flip. Imagine the guy guesses that the first card is a 10, and we flip over a 6. He should definitely guess 6 on his next go, because, compared with every other choice, there are only three sixes left in the deck on which he could potentially lose, compared to four of every other card. That seemed like a much better strategy. Unfortunately, with such a strategy, it becomes incredibly difficult to calculate the probabilities. And so I decided to spend the evening of my sun-filled day writing a small computer program to simulate the trick. Geek night had begun! And indeed, after  half a million simulations of a virtual victim playing our 'go with the last revealed card' strategy, it turns out that our odds of winning that beer drop to 95.7%. This still seems pretty good, but think of it this way: our victim's chances of winning have tripled, just by adopting the simplest technique possible. But he can do much, much better than this. For example, if he knows that three of the queens have come out, and then a 10 is flipped over, he's three times better off guessing 'queen' than '10'. And, of course, once all FOUR of one card value are flipped over, one just has to say that card over and over again until all the cards are dealt out, with a guaranteed win. It seems to me that the best possible strategy for guessing goes something like this:

  1. Guess a random card on the first go (and hope you don't get it right!)
  2. On the second go, say the value of whichever card was flipped over first
  3. From then on, guess the value of the card that has been flipped over MOST up to that point. If there are more than one value that has been flipped most (say, three kings and three queens), choose one of them randomly.

That's it. It's clear that this strategy is much better than the two rudimental approaches mentioned above - but just how much better? Is it worth the "$30 versus a beer" bet? For that, I went back to the computer code and got my virtual guesser to try out the strategy. The result? A staggering improvement in the odds. The clever victim has a 27.1% chance of making it through all 52 cards without a match - incredibly, almost 20 times more likely to win than just by random guessing. In fact, unless our beer is worth more than $11, we're expected to lose money on the bet. What sort of trick is that?! For those of you who watched the original Scam School video until the end, you'll notice that the host, Brian Brushwood, is aware of this little tick, and even asks viewers to calculate the exact odds of the trick's success and send it to him. Unfortunately, seeing that the video was posted in 2011, I guess I've missed the boat there. Anyway, at the end of the video Brian has some suggestions to try and make it difficult for the scamee to remember all the cards that have come before. But even so, the chances of a clever volunteer 'beating' the trick are a little too high for my tastes. I'll stick to the classics. (For those with any morbid geeky interest, I've copied my code for the simulations below. It uses Matlab, but the structure will of course work in any language, even Microsoft Excel.) Speaking of classics, check out Scam School's sneaky Stanford chess scam. Not bad.

clear all;clc;

c=13; %number of card types

t=4; %number of cards in a type

n=c*t; %number of cards

s=500000; %number of simulations

results=ones(1,s); %results of simulations. A one means a win.

g1=1; %let the first guess be one

    a=ones(1,t); b=[1:1:c]';

    deck=b*a; %creates a deck of all the cards

for k=1:s k

    guesses=g1; %vector of executed guesses

    shuffled=deck(randperm(n))'; if g1==shuffled(1) results(k)=0; else for i=1:n             g=mode(shuffled(1:i-1));   %Use this for the optimal strategy.

           %g=shuffled(i-1);   %Use this line for the "use the last card" strategy

            guesses=[guesses; g]; if g==shuffled(i) results(k)=0;

                sprintf('On turn number %d the guess was %d and the card was %d',i,g,shuffled(i))

                break end end

 if i==n

disp('You win!');




disp('Proportion of wins:');