## 2011/08/31

### The Full Monty (Hall)

Warning: this post contains some mathematics. Please do not be afraid of it.

The so-called Monty Hall problem is fascinating in its simplicity coupled with a completely unobvious answer. It is a very good example of how people make probabilistic errors in making decisions. Even after confirming the maths, I still could not quite get it. My intuition is fighting with my reason and I cannot help but wonder if people routinely make these errors, whether I do.

Statement

The Monty Hall problem is based on a game show hosted by Monty Hall. The problem can be stated as follows (my own wording):

You are shown three boxes and must pick one. One of them contains a prize, the others are empty. The box containing the prize has been chosen randomly. After you have chosen a box the host will show you the contents of one of the other two boxes (it will be empty). You are then given the option of either changing your choice (and choose the remaining closed box) or sticking to your original choice. What is the probability of winning if you switch versus if you do not? Assume that if both of the unchosen boxes are empty one will be chosen at random to be opened.

The “obvious” answer, the one most people choose, is a half. That is, does not matter whether you switch or stay, the prize surely has an equal probability of being in either box.
Wrong. The probability of winning if you switch is two thirds and only one third if you do not. This is counter-intuitive. I myself, believing and having seen the maths, still find it hard. By showing the contestant one of the boxes Monty gives the contestant extra (useful) information. However, it would appear that this is information that our brains were not made to process very well.

Preparatory

Before we solve the problem, let us set up some things we will need. Let P be the box with the prize. P is 1,2 or 3 with probability one third. Let C be the box initially chosen (we will assume this is box 1). Let S be the box that Monty chooses to show to the contetant.

As I phrased the problem above, the solution is the probability of winning if you switch, given that box S was shown, which can be put in maths as (assuming box 2 is shown)
$Pr(P=3 |S=2).$

One thing to note is that the solution is NOT the probability of the prize being in box 3 given that is is not in box 2 or
$Pr(P=3 | P \neq 2)$
This is, in fact, a half, but we have been given more information than just that the prize is not in box 2 (even if we have trouble seeing it).

We could also decide to calculate the probability of winning given that the contestant will always switch. That is, we find the probability of winning before we know which box is shown to be empty, knowing the contestant will switch. This is the probability of winning with box 3 (if box 2 is shown) plus the probability of winning with box 2 (if box three is shown) Remember the contestant switches away from box 1. This can be shown in maths as
$Pr(P = 3 | S = 2) Pr(S = 2) + Pr(P = 2 | S = 3)Pr(S = 3).$

There is a subtle difference between these two formulations, which adds to the confusion. Lets call the first problem A and the second one B. Given the way I formulated the problem, most crucially the very last line, the two answers are the same. However, A’s answer will change if I modify the last line and B will remain at two thirds.

Solution 1

A very simple solution to problem B is given by drawing a table of the variables. We have P for prize and E for empty. Remember we assume the contestant chooses box 1 initially.

 Box 1 Box 2 Box 3 S Result on switch P E E 2 or 3 lose E P E 3 win E E P 2 win

Each of the three configurations of the boxes is equally likely and thus it must be that, if you switch (always) you win with probability two thirds.

Solution 2

A, perhaps, simpler way to solve B is to observe that the contestant loses if and only if they initially choose the car. This happens with probability one third. So the probability of winning must be two thirds.

Solution 3

An intuitive explanation for the result is to consider the two unchosen boxes together. These boxes must, together, contain the prize with probability two thirds. So switching will give the combined contents of the two boxes with probability two thirds (as one box will be revealed and the other can then be chosen).

Note that this does NOT mean that by revealing that one of the two boxes is empty, the other must therefore now contain the prize with the same (two thirds) probability. This explanation is appealing, but it is incorrect. Merely revealing which of the two remaining boxes is empty is not enough. We also need to know how the empty box was chosen (the last sentence of my problem statement). I will demonstrate this in the next solution.

Solution 4

Let us try a somewhat longer and comprehensive algebraic solution that will allow us to fully distinguish between A and B. First let us solve problem A.

By Bayes Theorem:
$Pr(P = 3 | S= 2) = \frac{Pr(S = 2 | P = 3)Pr(P = 3)}{Pr(S = 2)}.$

We know
$Pr(S = 2 | P = 3) = 1$
as Monty must show the empty box if there is a prize in three and
$Pr(P = 3) = \frac{1}{3}$
by definition.

Now to get the probability that box 2 is shown we can add the probability that it is shown and the prize is in box 1, 2 and 3 respectively.
$P(S = 2) = P(S =2 | P =1)Pr(P=1) + Pr(S=2|P=2)Pr(P=2)+P(S = 2| P =3)Pr(P=3).$

The middle term is zero as Monty would not show us the box with the prize and the second factor of each term is one third. This gives
$P(S =2) = \frac{1}{3}(Pr(S = 2| P =1) + 1).$

The key term is
$Pr(S = 2 | P =1).$
Let us call it q for now. This term explains how Monty chooses which empty box to show us. In the standard formulation q is 0.5 , meaning Monty chooses randomly. If q is 1 then Monty will always show the second box, if it is open (we could say Monty prefers to open the leftmost box)1.

The answer we are looking for is then
$Pr(P=3|S=2) = \frac{1}{q+1}.$

This ranges from ½ when q = 1 to 1 when q = 0. The value is two thirds in the standard case where q = ½.

When q =1 we get what is the intuitive answer. Each of the remaining two boxes is equally likely to have the prize. When q = 0, we know that Monty would not open box 2 if given a choice. So, the fact that box 2 is open means the prize must be in box 3.The fact that the probability of winning is always at least a half, means that it never hurts the contestant to switch.

What’s interesting is that the answer to problem B does not change, no matter what q is. This means that for a person playing the game, the probability of winning given which box is shown may vary, but on average, a person who always switches, will win two thirds of the time. We can easily show this by calculating
$Pr(P = 3 | S = 2) Pr(S = 2) + Pr(P = 2 | S = 3)Pr(S = 3).$

Let us do a simple numerical example. Suppose q is 1. So we know that if box 2 is opened there is probability 0.5 of winning. However, if box 3 were opened instead we would KNOW that the prize is in box 2. Monty would not have opened box three if box 2 were open. So we win with probability 1. However, before we know which box is opened, the probability of winning is
$\frac{1}{2}\times\frac{1}{3}(1+1) + 1 \times\frac{1}{3 \times 1} = \frac{2}{3}.$

In general both terms of the expression for B are easily seen to always be one third 1/3. By similar calculations to that I already did Pr(P = 2 | S = 3) can be found and the expression calculated. This gives the solution.

Why do we get it wrong?

The answer, probably, has something to do with our brains. Perhaps we are just bad at intuiting probabilities. As few as 13% of people choose to switch. People appear to have a tendency to think probability is evenly distributed across any possible outcomes.

The status quo bias may also partially explain it. People tend not to change something unless there is a very compelling reason to do so. People may also tend to value something more highly once it is their property or they have a right to it. This is the endowment effect and is a form of the status quo bias. Here it is that people value the box they already have more than the others.

I think, possibly, we have evolved (or been taught) to stick to things. So if we start something, we have to finish it. If we make a decision now, and later change our minds, we’re seen as fickle, undependable. And so, perhaps, from this we have a tendency to believe that our initial choice is correct. So we don’t switch.

Markets

I find the Monty Hall problem interesting because similar reasoning in the markets (which are so much more complex) means traders might make irrational decisions. The market will not be efficient. The irrationality of the traders can (potentially) be exploited by others (possibly computers) who notice it and who do not make the same errors. However, whether these kinds of errors are easy to detect is not clear and they may not be nearly as simple as this little problem.

Some references

On the problem

A popular science-type book that has a section on this problem
• Crilly, T. (2011). The Big Questions Mathematics. (S. Blackburn, Ed.). London: Bloomsbury.

On biases

1 An important thing to realize is that if you do not KNOW that Monty is selecting doors with probability q, from your perspective it is random and you should treat q as ½.

## 2011/08/14

While researching my previous post I came across the following site: http://www.algotradingmachine.com/

It claims to send you a number of stocks to buy every morning in return for a monthly subscription fee. The stock picks are supposedly based on an algorithmic analysis done by highly sophisticated computers.

This offering has all the makings of a scam:

• Outrageous promises, such as that there is no risk involved. NO investment professional would EVER promise you a no-risk product in speculative markets. NOT EVER.
• In reality they only claim to give you your subscription fee back. You still carry the risk of all your trades. Such misleading statements would not be used by true professionals.
• A cleverly hidden disclaimer contradicts the claims of riches and no risk and will result in victims not being able to reclaim their money when they find the promised wealth does not materialize.
• The disclaimer also makes it clear that the “profit” statements shown are only simulations. This is not shown anywhere else, and is highly deceptive.
• The so-called professionals behind the scheme who are supposedly the best in their field are never mentioned, so we cannot confirm this claim.
• Testimonials shown do not have their authors identified. There is no way to know if these are not made up.
• The strategy is supposed based on “Fundamental Analysis” like that used by Warren Buffet. In reality algorithmic strategies generally are not based on fundamental analysis, which in any case would not really work for short holding periods of only a day.
• Claims that price will soon increase based on high demand are supposed to encourage you act quickly. This is just playing psychological tricks.
• Gaudy and glaring website design with overly huge fonts, too much info on a single page, and the use of post scripts point to tomfoolery.

DO NOT subscribe to this service. You have been warned.

I have not found any official sources confirming my suspicion. If you can either confirm or correct me (and prove it), please do so.

Algorithmic trading (also called automated trading, black-box trading or robo trading) has taken off in a big way. It is much bigger, I think, than most people realize. By the latest (2009) estimate I could find, algorithmic trading accounts for over 70% of trading volumes in the USA. We have given our wealth into the hands of algorithms, executing strategies not even their creators understand. Is this wise or yet another naive trust that will only result in a repetition of history?

Algo-trading is simply the use of computer algorithms to automatically execute trades. In many cases the algorithms will not only decide on what to trade, when and how, but also initiate the trades themselves. The algorithms take as input a range of financial data, such as share prices, or even news articles, analyse it, spotting patterns, and then trade so as to achieve the highest profit (or some other goal).

Why use it?

Any tool in the world of finance has to do one of three things (a) make money, (b) reduce losses, or (c) reduce risk. Algorithmic trading can potentially be used for all three.

One of the simplest (and seemingly benign) uses of algorithmic trading is to break up a large transaction into a number of smaller ones. A large fund may wish to buy (or sell) a large amount of a certain stock. The problem is, should it wish to put in a trade for the whole amount, it will almost certainly move the price against itself. Other traders, seeing that the fund wants to buy (sell) a large amount of stock will increase (lower) the price at which they are willing to trade.

The fact that the fund is trading is a market signal. It indicates that the fund values the stock differently from the market. In order to reduce this signal, to reduce its market impact, (i.e. to hide) the fund will therefore do a number of small trades over a period of time. This can allow the fund to trade with a smaller market impact and thus at a better average price.

Another, very common use of algorithmic trading is known as High Frequency Trading (HFT). Here the algorithms attempt to profit by spotting patterns or price discrepancies in stocks over very short periods. Stocks may only be held for a fraction of a second. The profit made per trade is very small, but multiplied by millions of trades it can add up to large amounts.

The good

Algorithmic trading is claimed (by its proponents) to have increased liquidity in the market liquidity (in this context this means there are more trades and more opportunities to trade), which is mostly seen as positive. This liquidity comes from the fact algo-traders create trading opportunities by offering to buy or sell securities. Many act as market makers, offering to buy at one price and sell at a higher price, profiting from this difference and giving others the opportunity to trade.

Algo-trading has also lowered market spreads (the cost of trading), which is the difference between the sell and buy prices mentioned above. The gap used to be quite large, but is now very small. With many traders competing to profit from the spread, the gap between the two prices has decreased.

Algorithmic strategies could potentially make markets more efficient (whether they actually have done so is not certain). They allow prices to react more quickly to data. Algorithms can read the news much faster than humans and trade within microseconds. They reduce arbitrage opportunities by actively looking for and taking advantage of them.

Algorithms can reduce market volatility; at least the right algorithms (or rather combination of algorithms) can do so. They can do so via a process of negative feedback. This means that an increase in the price of a stock is an indication that it may fall soon and thus signals traders to sell the stock. Such selling will then result in a reduction (or smaller increase) in the price of the stock. A less volatile market is a safer market, encouraging more investment and giving firms access to finance at a lower cost.

By their natures, computers have certain advantages over humans, which can prove useful in investment. The first is that computers can analyse a lot of data far more quickly than a human can. Algorithms can trade on patterns within thousands of stocks, following strategies humans could not comprehend. Because they act so quickly it is possible to take advantage of opportunities that only exist for seconds and to beat (slower, human) competitors.

Another computer attribute, which I have not seen discussed, is the fact that computers do not have emotions. Investment pundits often warn against emotion in making investment decisions. Algorithms can take the emotion out of investing. Human traders may be tempted to make emotional decisions, but algorithms will (if programmed to) always act rationally.

Paul Wilmott, an eminent quant whom I have mentioned before, has expressed his concerns about HFT as it is currently practiced. Wilmott worries that algorithmic trading can create a separation between value and price. The HFT algorithms are not concerned with the intrinsic value of a stock, only how the price may move in the next few milliseconds.

Even though algorithmic strategies do often look at news events and try to trade based on the news, there is a danger that fundamental drivers get left behind. With so much trade being driven by algorithms all that really matters is whether you can compete with the other algorithms, not whether demand for coffee or cement is up.

Another of Wilmott’s fears is that HFT can lead to positive feedback (the opposite of the negative feedback I mentioned earlier), which exacerbates market volatility. With positive feedback, an upward movement in price tends to cause further upward movements and similarly for down movements. Ominously, there is an incentive for funds to create such feedback. In volatile markets there is the possibility of making very large profits (if you trade in the right direction); however, should you lose all your client’s money it is your client that loses, not you. In more stable markets less skill is needed to make money and there would be less need for hedge funds and their very high fees.

The liquidity provided by algorithmic traders can easily vanish. Algo-traders are (currently) under no obligation to stay in the market and can choose to withdraw. This would most likely happen in volatile and uncertain market conditions when the traders do not want to risk being active in the market. This happened during the flash crash, which I analyse later. Algorithmic trading may be good in the good times, but in the bad times, it may make things worse.

The large volumes of orders that algo-traders can generate can overwhelm stock exchanges, forcing them to shut down. There are notable examples of instances where indices had very large lags in being computed, trades were delayed, or exchanges had to shut down trading due to an excess of orders. The majority of the extra orders may well be from algorithmic trading. Algo-traders often place orders that are then cancelled almost immediately, which also contributes to volumes.

It is hard to predict what the effect will be of all these algorithms interacting in the market. They are just too complex. Computer “panic” could erase wealth in seconds. A small bug could cost you (or someone else) their life savings. The very speed for which algorithmic trading is designed also poses much of its danger. The algorithms can spiral out of control very quickly and do a lot of damage before humans can intervene.

The ugly

Algorithmic trading has turned investment into a war. The algorithms compete against each other, each attempting to gain some advantage over the others. Paul Kedrosky calls them “battle bots”. A part of the strategy of some algorithms appears to be to send a large number of quotes into the market, merely to overwhelm and confuse competitor algorithms. Will other traders be the collateral damage of this war that is fought on our markets?

There is also some animosity toward algorithmic traders for having an unfair advantage. They effectively have access to faster and better information than ordinary traders. In some cases they even pay to get quotes a fraction of a second earlier than the rest of the market. Eventually, algorithms may all but drive human traders out of the market.

Lord Myners, a former financial services secretary in the UK, fears that algorithmic trading removes the owner-relationship from shares. You are hardly an owner if you keep a share for only a few milliseconds. The company you buy is hardly accountable to you, then. The algorithms do not care if the underlying business is run well or whether it makes profit.

Another portent is the black-box nature that these strategies can assume. The algorithms can be seen as boxes that take share data as input and output trades. However, what goes on inside the box may not be well understood or may be a mystery even to the programmers. With some strategies, the box chooses the optimal strategy based on patterns it observes in the markets. The strategy it chooses may be very complex (far more complex than humans could hope to understand) and may change frequently. The lack of control we have over the eventual outcomes of our algorithms may be unsettling to some.

Black Monday

On 19 October 1987, known as Black Monday, stock markets crashed. This was the largest one-day percentage decline in the Dow Jones in history at 22.61% (New Zealand’s market fell by as much as 60%). Program Trading, an early form of algorithmic trading is oft blamed for the crash. (Remember, though, that causes are very easy to assign retrospectively and there is still no clear consensus as to the actual cause.)
In this case program trading was used for dynamic portfolio insurance (DPI). The aim of DPI is to protect a portfolio against large drops in the market. As the market falls, the strategy will sell shares, reducing your exposure and thus protecting you against a further drop. The danger in this strategy, if collectively followed, is actually quite obvious.

If the market falls a little and a lot of people sell shares, or rather their DPI strategies sell the shares for them, it will cause the market to fall even further, causing people to sell more shares... and the result is that DPI causes what it is meant to protect against. This is an example of positive feedback causing a crash. Working in the opposite direction it can cause bubbles.

Flash Crash

On 6 May 2010, the Dow Jones lost several percentage points almost instantaneously, and then recovered within minutes. This very rapid anomaly is known as the Flash Crash (or The Crash of 2:45). There is still much debate as to the cause and I am certain it is not nearly as simple as most theories would claim, but algorithmic trading may be to blame.

One possibility is that HFTs reacted to a large sell order of futures. This order was being implemented by an algorithm and was to sell the futures without regard for price or timing1 – this resulted in the futures being dumped far more quickly than expected. The HFTs then also started selling these futures, driving the price down even further in what is called hot potato trading2 . The HFTs bought the futures then sold them again very quickly, to each other, passing them back and forth, creating a cycle of price declines. This then spilled over into the equity markets. In the latter market, many HFT traders actually withdrew and this caused some shares to sell at very low prices.

What is truly interesting about the flash crash to me, is the quick recovery. Perhaps traders (probably human traders) realised the prices were ridiculously low and started buying, wiping out the crash. One analyst, while giving a television interview and seeing the price of P&G had plummeted, urged people to buy the stock immediately. It is also worth noting that some think the HFTs may actually have played a stabilising role, that is they prevented the crash from being even more severe.

The arms race

HFT requires speed and the ability to trade before others can act on information that affects the market, to make use opportunities that may only exist for very short periods. Computers need to make millisecond decisions and trades. This is because their real competition is not human traders (who react slowly) but other high frequency traders. This has resulted in a kind of latency3 race, in which companies try to make their trades faster and faster.

This race has pushed funds to what seem like absurd measures just to gain a few microseconds. Fibre optic cables have been laid across the US just for these strategies; companies have located their trading operations right next to the servers from which internet access is distributed; programmers have reconfigured operating system kernels (notably Linux kernels) for optimal speed.

Algorithmic strategies always need to change. Competition between firms and changes in the market dynamics mean that the strategy employed needs to involve. Competitors reverse engineer the strategies of their competitors, and exploit them. Then their competitors need to change. Those familiar with evolutionary algorithms would know that it is even possible for the algorithms to adapt themselves. This brings us much closer to markets ruled by a Skynet4 that we do not fully understand.

South Africa

From what I understand algorithmic trading (indeed quantitative strategies in general) are not prevalent in South Africa. The market is not nearly as deep as those of more developed countries and this makes it harder to obtain enough data on enough stocks to find patterns to trade on. As South Africa develops and the market becomes more sophisticated this is likely to change.

Skynet

The equity market is no longer driven by humans. Computers decide the price movements that dictate our wealth. Now, this is not in itself a bad thing. As I have said, computers have many advantages over humans. The transfer of tasks from humans to machines has fuelled economic growth for the past 200 years.

A bunch of algorithms vying for dominance in the financial markets is not really all that different from human agents doing the same thing (except that the algorithms are so much faster). Human interaction is at least as complex and as difficult to understand. Human error can be as disastrous. At least with computers, there’s an instantaneous off-switch

However, there are signs that this emerging Skynet is making the markets a far more dangerous battlefield. The flash crash was not an isolated incident. Many similar such crashes have occurred in individual stocks and other non-stock markets, but they have not yet been brought to the public eye. I like algorithms. I find the idea of letting a computer do my trading appealing. But it is foolish not to consider the repercussions this could have.

Some references

General

• Heires, K. (2009). TRADING ON THE NEWS: Turning Buzz Into Numbers. Securities Technology Monitor. Retrieved from http://www.securitiestechnologymonitor.com/issues/19_104/-23976-1.html?zkPrintable=true
• MacSweeney, G. (2007). Pleasures and Pains of Cutting-Edge Technology. Wall Street & Technology. Retrieved from http://www.wallstreetandtech.com/articles/198001836
• Rogow, G. (2009). Rise of the (Market) Machines. Wall Street Journal Electronic Edition. Retrieved from http://blogs.wsj.com/marketbeat/2009/06/19/rise-of-the-market-machines/
• Salmon, F., & Stokes, J. (2010). Algorithms Take Control of Wall Street. Wired.

Flash crash

• Bowley, G. (2010). Lone \$4.1 Billion Sale Led to “Flash Crash” in May. The New York Times. Retrieved from http://www.nytimes.com/2010/10/02/business/02flash.html?_r=1&scp=1&sq=flash+crash&st=nyt
• Goldfarb, Z. A. (2010). Report examines May’s “flash crash,” expresses concern over high-speed trading. The Washington Post. Retrieved from http://www.washingtonpost.com/wp-dyn/content/article/2010/10/01/AR2010100103969.html?sid=ST2010100107554
• Lauricella, T., Scannel, K., & Strasburg, J. (2011). How a Trading Algorithm Went Awry. The Wall Street Journal. Retrieved from http://online.wsj.com/article/SB10001424052748704029304575526390131916792.html#project=FLASHCRASH_CHART_1007&articleTabs=article
• Mehta, N., & Kisling, W. (2010). Futures Sale Spurred May 6 Panic as Traders Lost Faith in Data. Bloomberg. Retrieved from http://www.bloomberg.com/news/2010-10-01/automatic-trade-of-futures-drove-may-6-stock-crash-report-says.html
• Spicer, J. (2010). Special report: Globally, the flash crash is no flash in the pan. Reuters. Retrieved from http://www.reuters.com/article/2010/10/15/us-flashcrash-europe-idUSTRE69E1Q520101015
• Spicer, J., & Younglai, R. (2010). UPDATE 4-Single U.S. trade helped spark May’s flash crash. Retrieved from http://www.reuters.com/article/2010/10/01/financial-regulation-flashcrash-idUKN0114164220101001
• Younglai, R. (2010). U.S. probes computer algorithms after “flash crash.” Reuters. Retrieved from http://www.reuters.com/article/2010/10/05/us-flash-crash-idUSTRE6945LH20101005

Black Monday

Paul Wilmott

Market impact

Market makers

Lord Myners

Paul Kedrosky