Friday, July 10, 2009

Two Coins Revisited


Last time we looked at the classic two coins problem, which (as a reminder) goes like this:

The host flips two coins. If both are heads, he flips again; if at least one is tails, he announces this fact. The contestant has to guess whether the other coin is heads or tails.


Without getting into the details, the contestant has a 2/3 chance of guessing correctly if he picks heads. The probability argument is simple, but nobody believes it anyways, so I won't repeat it here.


Clearly this is exploitable, since we can offer just above 50/50 odds to our mark as long as we can get them to play the host.


What I'm thinking about now: is it possible to very slightly alter the game so that we could let the mark play the contestant, at the same odds, and still make money? In other words, what is the minimal modification that actually turns this into a 50/50 game?


My proposal is that instead of canceling the game and re-flipping if we hit two heads, the host now gets to pick whether he tells the contestant about a head, or a tail, and we play each round.


Huh? WTF am I on, right? Isn't the game completely symmetrical, and we're just flipping it around so that we don't have to discard any tosses?


Au contraire. Let's enumerate the possibilities, assuming that if HT or TH comes up my choice of which to announce is completely random:


  • (25%) HH - announce heads
  • (12.5%) TH - announce heads
  • (12.5%) TH - announce tails
  • (12.5%) HT - announce heads
  • (12.5%) HT - announce tails
  • (25%) TT - announce tails


No big surprises there.


But let's start our arithmetic. Suppose I've announced heads. Out of a total 50% probability for that case, 25% comes from HH, 12.5% comes from TH, and 12.5% comes from HT. In other words, given that I've announced heads, there's exactly a 50/50 shot that the other coin is heads!


So what happened to the 2/3 from the correct answer to the previous problem? It's gone, plain and simple, and we're back to a fair even gamble again. You can figure out where it went by looking at that table above: now instead of being forced to announce heads in both the TH and HT case, we can split our call 50/50, and the bias is gone.


If you ever try this in real life, the way to do it is to first take the mark's money for a while as the contestant, and then when they're starting to get the sense that they've been had, suggest that you for expediency's sake you just start playing every flip, and that they can choose whether to call heads or tails when they flip. Only let this go for a round or two, though, because you're now playing a slightly losing bet. Soon thereafter, suggest that maybe they'd have better luck on the other side of the table, and let them play the contestant. Pull it off right, and they'll never even suspect that you slipped in a rule change that tilted the game in your favor; as long as you then proceed to play longer as the host under the new rules than you did as the contestant, the ruse has decidedly positive expected value, and the additional bonus that you leave the mark feeling as if they had a fair shot the whole time.


I'd wager some pretty good bank that you could even sucker quite a few people that understand the original problem into this version...

Taking People's Money


By now pretty much everybody has heard of the Monty Hall Problem, even if they generally don't know the right answer. It has a long history of pissing people off, and ranks right up there with the airplane on a treadmill as being one of the most hotly contested thought experiments ever.


My current concern is using this problem (and people's insistence on misunderstanding the answer) in order to trick people out of their money, because that's just how I roll.


First, just in case you're not familiar with the details, we'll re-cast the problem as something you can screw people over with in real life, where you hopefully would have some trouble coming up with a goat on short notice:


  1. Obtain a napkin, two pennies, and a quarter.
  2. Tear the napkin up into three pieces.
  3. The "host" places each of the coins under a separate napkin, making sure that the "contestant" cannot see where each one is.
  4. The contestant picks a napkin, aiming for the quarter.
  5. The host uncovers one of the pennies, without telling the contestant whether he's picked correctly or not.
  6. The contestant has a final opportunity to switch his choice.


The problem is, it's a little difficult to exploit the game as it stands. People intuitively think that the contestant has a 1/3 chance of winning, whether or not they switch sides. They assume that they would be completely indifferent to switching, and if you offered them what they would perceive as "fair" 1/3 odds, you'd lose money in the long run because they will occasionally switch. If you offer something closer to the true fair odds (1/2), they're not going to play because they see it as extremely weighted in your favor.


So let's switch things up. Allow the mark to play the host. Now we can take the role of the contestant, and assuming our mark is a good target, they will feel like they are getting a "good deal" when you offer to put up $5 for every $6 that they throw into the pot. After all, they should win "2/3" of the time, right?


And now you're +10% expected value each time you play the game. Only real problem now is finding someone sober enough to sit down and listen to the rules of the game and think about it enough to "realize" that 5:6 are odds that they should take.


Perhaps even simpler is the two coins game. Here's the way this one works:


  1. Host flips two coins, hides the results from the contestant.
  2. If both coins are heads, host shows the coins (so contestant knows the host isn't lying) and starts over.
  3. If at least one is tails, the host announces this fact.
  4. Contestant guesses what the other coin is.
  5. Contestant wins if his guess is correct.


Now, the scam here is that most people think "fair" odds for this game are 50/50. Obviously, right?


Well, that's wrong. In reality there's a 2/3 shot that the other coin will be heads. See Jeff Atwood's blog for a lot of discussion. Many people won't believe this even after it's been explained to them.


The nice thing about this version of the problem is that people have a real affinity for 50/50. Flip a coin? Even bet, obviously. A lot simpler than having to think about an ostensible 2/3 bet and decide whether 6:5 odds is giving them value or not.


With this one, we again want to take the contestant side. We can play the host as well, but it's harder to explain and sell the extra conditions we need to add to make this a +EV play (these changes will (correctly, for once!) make the mark think the game is tilted against them), so it's simpler to stick with playing the contestant. It also puts the coins in the mark's hands (let them use their own!), so they feel more comfortable that they're not being swindled.


Offer them odds slightly better than 50/50, but don't go further than 2:1, that's your break even point. $6 of yours to every $5 of theirs should do the trick, though $11 to $10 is even better, if you can sell it. You always go for heads, and you're set.


A tip: try to specify the number of rounds you're going to play beforehand. A lot of marks will stop once they've lost a little bit, and this option has value. That won't hurt you in the long run, so you won't end up in the red if you don't do this (the ability to stop playing is more like a stop loss order in the stock market; it is only worth anything in this case because the game has -EV for the mark), but if you can lock someone in to 10 rounds, go for it!


A bit of advice: people that feel confident about probability estimates can often make great marks here, because once they've arrived at the wrong answer they are absolutely certain that it is correct. Think poker players, mathematicians, etc. - overall they tend to be only slightly better than average at figuring out the right answer, but they end up far more committed to their answers, so they'll really dig in and chalk the losses up to "variance."


And that's what we refer to as "getting our lulz."

Tuesday, April 21, 2009

Logarithm, The Bastard Monomial

I haven't done a mathnerd post yet. I think it's about time, but alas, I lack the time to write a fresh one right now; this is migrated from my now defunct math blog, and should prove beyond a shadow of a doubt that I'm a total weenie. This series will move into some fun stuff soon (if you're a loser like me), so stay tuned...

So you think you understand elementary calculus, eh? Good for you, but let's go slow at first, just to be sure. We're going to start at the beginning: finding the integral of a power of x.



Or as an indefinite integral



Of course, this is not the case for n=-1; indeed, if n=-1 then the denominator becomes zero. The indefinite integral in that case is



Something seems fishy here, though. After all, the difference between and is just about nil for a specific value of x; can it really be the case that the antiderivative is so different that we actually need a different functional form?

No! Miraculous as it may seem, the natural log function is, to some extent, the magical in-between value between the powers of x that blow up at x=0 and remain zero there. Huh? Let's look further...

If we didn't happen to know that the antiderivative of 1/x is the ln function, we might inquire as to what happens in the limit as n -> -1 in the expression for the antiderivative of a power of x. An excellent question is, from which side? Well, we should look at both, as a rule. From above, we get, for small epsilon approaching zero



whereas from below we get



Just for fun, let's look at the value x = e. Using the Taylor series for e^x = 1 + x + x^2/2! + ... we see that the first expression becomes



Interesting - in the limit as epsilon approaches zero, the 1/epsilon will diverge to infinity, and the rest approaches 1 (each term except epsilon/epsilon goes to zero). Perhaps we can absorb that 1/epsilon into the constant of integration and declare that this is equal to 1? [In which case we have verified, at least for this particular case, that this limit appears to match what we'd expect of the ln function]

This seems a shady - it smacks of the renormalization tricks that physicists love to play, haphazardly discarding infinities whenever they are inconvenient. In this case, it's not nearly as sinister as it looks; I'm just saving a bit of time by working with the indefinite integral instead of the definite one, where that infinity would never crop up in the first place - I encourage you to try it yourself.

And we have a bonus: as it turns out, both the "from above" and "from below" expressions turn out to be equal in the limit, as long as we remove those infinite terms in the appropriate way (or work with the definite integrals instead).

Without further ado, the punchline: a few lines of algebra will quite easily confirm that the limit expression



serves quite nicely as a definition of the natural logarithm function, at least over the positive real numbers; when we move to the complex plane, things become a little trickier because one must specify quite precisely what is meant by that limit and by the raising of x to that power (recall that complex roots may be multivalued).

So to make a long story short, the logarithm function is not a special case at all, nor do we have to resort to its status as the inverse of the exponential function to define it naturally. It's simply what we get if we look at a series of monomials normalized so that their derivatives are pure monomials (w/o constant factors) and push through zero. Modulo normalization and a shift, the logarithm is "merely" a non-constant power of x with zero exponent, which is pretty cool.

In fact, recalling that the inverse of the x^n function is x^(1/n), we see that the exponential function is, in a sense, a power of x with infinite exponent (again modulo normalization and a shift). From the expression for the ln function shown above, you can even derive the usual limit expression (the product one) for the exponential function (exercise!).

Next time: we're going to start with the first of many "proofs" that 0 = infinity, 0 = 1, and 0 = just about anything you want it to equal. Amusingly enough, a couple of these "proofs" are arguably correct and even (gasp!) useful, as long as you know what you're talking about when you write down the symbols!

Sunday, November 30, 2008

Value at Risk and the Failure of Self Interest in Real Life Economics

An interesting article at the NY Times delves into the concept of Value at Risk and analyzes its role in the current economic disaster. It's an interesting read, and you should definitely go through it if you've got the patience.

If you don't want to read the article, here's the brutally inaccurate summary:

  1. Value at Risk (VaR) is a way of measuring with a 99% certainty how much money you're possibly going to lose based on your portfolio
  2. What if you hit that 1% "jackpot" and lose more than your VaR? Who knows...you could lose twice your VaR, or a thousand times it. VaR doesn't distinguish, and it tells you nothing about the expectation value, either - your VaR could be $1, but your expected loss might be $1000. And you'll lose more than your VaR eventually - 1% ain't that small a chance!
  3. Regulators allowed companies to use internally calculated VaRs to set cash reserve levels. Stupidly.
  4. Managers paid more attention to 1) than 2). Stupidly.
  5. Traders took on as much risk as they could find while staying within the bounds of the VaR requirements. Stupidly? Ha - don't be so quick to judge!
  6. ...
  7. We all know the rest, and it has nothing to do with profit!


This has all been discussed to death elsewhere, so we'll leave most of it alone.

Ah, the traders, though. Arguably the only people that haven't done anything stupid here. 'What?', you say, 'they're the ones that started this whole thing, without them it couldn't have happened at all!'

True enough.

But from an economic point of view, the traders were acting rationally, thanks to the way they get paid. You know, that thing where they get reviewed every year, and either get a hefty bonus based on their profit, or get canned if they've been losing?

That's what we call an asymmetric risk profile. The upside is limited only by the maximum gain that the trader achieves over the year, which is a pretty astronomical number if they're either very good or very lucky. But the downside is just a lost job. Boo hoo. On to the next bank, I suppose, unless you've already got enough money to sit on it and retire. Or maybe you just start your own fund - hey, John Meriwether ran Long Term Capital Management into the ground to the tune of $4.6 billion, and after that massive failure he went on to...surprise!...start up a brand new billion dollar Greenwich hedge fund! That's what I call punishment for failure!

I digress. The point is, traders have a significant self interest in taking on as much risk as possible. After all, if I told you I would give you a 50% chance of making $N along with another chance to play my game vs. a 50% chance of getting nothing, and the only choice you had was what number to pick for N, what would you do? You'd set N as high as I'm willing to let you, since your expected payout is .5*N.

Now, there's a peculiar thing about financial markets. If you were trading plain old stocks for a company, you'd be in exactly the situation I've outlined. And it would still have a pretty massive expected payoff, as long as you're allowed to set N high enough. But then people invented wonderful things called derivatives, which let you shuffle risk around pretty much at will.

You want a sure thing? No problem - write a boatload of deep out-of-the-money options, millions of them (writing an option is the inverse of buying one - you take an up-front fee and offer someone the right to purchase a share of a stock at a given price from you). They'll probably never be exercised, so you're almost sure to make a lot of money. It's like a money printing machine! Seriously, you're almost guaranteed to make money - the only reason more people don't do it is that you generally need to get special permission from your broker to write naked options.

The catch? That one-in-a-million shot that the option you've written pays out has to balance the odds, so you'll lose a lot of money if it hits. Like, a million times more than you made by selling them.

You're now allowed to change the odds however you'd like, but the payout profile changes, too.

Balance is restored...unless you're a derivatives trader playing with someone else's money, that is!

Because now you can play my game differently. Instead of playing a 50/50 game, you can make it a 99/1 game, so you're almost definitely going to end the year with a bunch of cash. And the 1% chance that you lose means that whoever fronted the money is really screwed now, but what do you care? You're an economically rational agent in search of maximized utility, and that 1% option only reduces someone else's payout, not your own. Yay rationality!

Extra bonus: if the riskiness of your bet sneaks by with under 1% uncertainty, it doesn't affect your VaR measurement, so you can push N ever higher and further increase your payout! Why isn't everyone in this business? Thank the Lord for financial derivatives!

When the house of cards comes toppling down, the only loser is...well, everybody, that is, everybody except the traders, assuming they stashed away enough cash to last them while things were going well.

Now do you see why Warren Buffet famously (and presciently!) called complex derivatives "financial weapons of mass destruction"?

The Failure of the Free Market...?

But wait. In Econ 101 didn't we learn that the best thing for an economy is for each player to act in his own self interest, remaining as unregulated as possible while still preserving competition? Damn straight we did. And if we're even somewhat libertarian-leaning, we treat this as gospel. And let's be honest - who's not at least a little libertarian these days?

There's an implicit claim there, which we might call the...

Zeroth Law Of Free Market Economics: a collection of self interested entities united under a single banner functions as a larger self interested entity.

I urge you to reflect deeply on this if you haven't already. It's an extremely non-trivial assumption, but if it doesn't hold, almost all of the economic theory that you learned in college literally falls apart.

Without it, you can't consider a company to be acting in its own best interests, which means you can't even think about applying standard game theory to company-company interactions. You can't even bring up supply-demand curves when you're trying to price products, since they might be perverted by internal quotas and incentives. And if you tried to analyze things more accurately, the complexity would go through the roof, since the only way to consider the economy would be as a collection of loosely grouped individual people under a whole bunch of (possibly confidential and unknown) incentive systems, which is a lot more difficult to do than considering the groups of people as purely self-interested companies.

When laws like the Zeroth Law fail to hold, the bogeyman to blame is usually Government Regulation. Government Regulation is when an external influence changes people's individual payoffs, and in the process, changes the way they interact (in unpredictable ways, with many unexpected consequences), so that now, a collection of self-interested individuals does not necessarily do what is in the best interest of the collection. We see this all the time in practice, and it's part of what makes economics so difficult a subject. Once you start paying out unemployment benefits, and giving tax breaks to people in certain industries, it makes it all but impossible to predict anything.

So now, lest you think that I'm going to repeat the tired old Proper Libertarian Mantra and blame the financial meltdown on government meddling in the private affairs of business, let me come clean and get to the point. Meddling with payoff structures is at fault here, but this meddling had nothing to do with the government. It's entirely the result of the free market.

The fundamental problem with libertarian economics: a free, unregulated market allows private entities to meddle with payoff structures in ways that are just as disastrous as when the government does it. These payoff structures will arise completely organically, just because of the fact that when people organize, they tend to do these things. I have yet to hear the most radical right winger suggest that the way traders are paid had anything to do with direct government interference, and that's because it didn't. It emerged in the purest of senses from free market negotiations, and caused a group of self interested people to act against the collective self interest of their organization. Period.

Put more simply, if we want to talk reasonably about free market economics, we need to be more liberal in our definition of "government." Governments and government meddling are natural consequences of a free market - any time people organize, they start to form rules that govern their organizations. And these rules disrupt the assumptions of a free market, whether the "government" in question is a small research group, a startup company, a Fortune 500 company, or an entire country.

The extent to which meddling affects the economy overall may depend on the size of the "government" in question, of course - nobody will suggest that the way Bob handles things at his furniture store (yup, that Bob!) has nearly the same impact as when the President revamps the way investment inside the country is rewarded or punished. Maybe it is generally better to prefer small scale regulations as opposed to large, top-down ones.

But as the current crisis demonstrates, the internal affairs of a handful of companies in one sector have more than enough power to cause the entire economy to collapse, and perhaps it's worth considering the idea that maybe, just maybe, the real solution would have been for the Government (the real one) to step in and break up what has always been a predictably problematic compensation and management structure in the smaller "government" known as the financial sector. Pay traders ridiculous salaries, fine, and fire them if they don't perform - but don't tie their upside potential to the amount of exposure they take on while letting them take on fantastic amounts of exposure! The combination of asymmetric risk coupled with the scam whereby the traders can increase exposure almost without limit was a time bomb waiting to explode, and that had nothing to do with housing, credit, or anything of the sort.

So the next time a Libertarian (big-L) tells you that the current mess we're in is the result of governmental meddling, and the only way to avoid this mess would have been to have zero regulation, feel free to agree with them. As long as they accept the fact that the term "regulation" must necessarily include the formation of companies, which are, after all, mini-governments that can invalidate the Zeroth Law of Free Market Economics just as easily as the real government unless they are exceedinly careful.

A truly free market is a beautiful theoretical entity. But unfortunately in practice, it is very hard to come by, since humans acting freely always group and regulate their groups. Which brings us to...

The First Law Of Free Market Economics: a market will become non-free if the participants are allowed to organize into groups.

Since a free market must allow people to organize into groups, we prove:

Corollary: there can be no free market. Deal with it and let's try to find a realistic balance.