# Abrazolica

Exploiting a Hidden Bias

Imagine a coin toss bet where you call heads or tails before the coin is flipped. Call it correctly and you win $1, incorrectly, you lose$1. If the coin is fair then the expected return on the bet is zero. In the long run you win nothing.

Suppose however that you know, or suspect, that the coin is not fair. One side has a higher probability of coming up than the other. Let me call the more probable side $$A$$ and the less probable side $$B$$ and assign them probabilities as follows:

$P(A) = p + b$ $P(B) = p - b$

where $$p=1/2$$ and $$b$$ represents the degree of bias. The value of $$b$$ can range from 0 for a fair coin to 1/2 for a completely biased coin.

If you know which side of the coin $$A$$ is, heads (H) or tails (T), then you can call it and take advantage of the bias. The expectation per bet in this case is

$p + b - (p - b) = 2b$

and for $$n$$ bets you can expect to win $$2bn$$.

But what if you don't know which side $$A$$ is? Can you still profit from the bias?

Not knowing means that on the first toss all you can do is randomly call H or T. The probability that you call $$A$$ or $$B$$ is 1/2 and there are 4 possible outcomes of the toss:

1. $$A$$ is called and $$A$$ comes up, probability = $$\frac{1}{2}(p+b)$$
2. $$A$$ is called and $$B$$ comes up, probability = $$\frac{1}{2}(p-b)$$
3. $$B$$ is called and $$A$$ comes up, probability = $$\frac{1}{2}(p+b)$$
4. $$B$$ is called and $$B$$ comes up, probability = $$\frac{1}{2}(p-b)$$

Outcomes 1 and 4 result in a win and 2 and 3 result in a loss, so the expectation is:

$\frac{1}{2}(p+b) + \frac{1}{2}(p-b) - \frac{1}{2}(p-b) - \frac{1}{2}(p+b) = 0$

As you would expect, there is no way to exploit a bias on the first toss.

On the next toss however, you do have an advantage. All you have to do is bet on the same side that came up in the first toss. Using this strategy, if the two tosses are HH or TT you win and if they are HT or TH you lose. The probabilities for winning and losing are then:

$P(\mathrm{HH\hspace{0.5em}or\hspace{0.5em}TT}) = (p+b)^2 + (p-b)^2$ $P(\mathrm{HT\hspace{0.5em}or\hspace{0.5em}TH}) = 2(p+b)(p-b)$

and the expectation is:

\begin{align}(p+b)^2 + (p-b)^2 - 2(p+b)(p-b) & = ((p+b) - (p-b))^2\\& = 4b^2\end{align}

For any bias, however small, the expectation is positive. If you continue to use the strategy of always betting the same as the previous toss for a total of $$n$$ tosses then you can expect to win $$(4b^2)n$$. This sounds good but you also have to look at the variance. To get the variance just add the win and lose probabilities and subtract the square of the expectation. This comes out to be $$\mathrm{Var}=1-16b^4$$. If you play this strategy for $$n$$ tosses then the total variance will be $$n$$ times this. When the bias is small, the variance is large.

I ran a simulation of using this strategy 10,000 times for $$b=0.1$$ and $$n=100$$ tosses each time. Averaging the 10,000 results and doing this 5 times gave the following: 3.694, 4.1858, 3.833, 3.9444, 4.1914. These results are very close to the formula given above: $$(4b^2)n = (0.04)99 = 3.96$$. These numbers don't tell the whole story however. The range of the results for one of the 10,000 runs of 100 tosses is from -42 to +46. The variance or volatility of this strategy is extreme.

But there is a better strategy. Instead of using just the information from the previous toss, use the information from all the previous tosses. You do this by counting the total number of heads and tails in all previous tosses and then betting the same as the one with the higher count. This is a majority rule: always bet the same as the majority. If the number of heads and tails is equal then revert back to betting the same as the previous toss. This strategy will get you close to the situation where you know which side $$A$$ is and always bet on it. The expectation gets closer and closer to $$2bn$$ as n increases. (The actual calculation of the expectation and variance is somewhat tedious and not something I want to put in a blog post.)

I ran the same simulation as above but using the majority rule. Doing it 5 times got me the following results: 14.7028, 14.2794, 14.3154, 14.3902, 14.6416. These are almost a factor of 4 better than the previous strategy. It is not quite as good as $$2bn = 19.8$$ but its close. The range of results for one of the 10,000 runs of 100 tosses is from -30 to +52 which suggests that the variance may not be quite as large for this strategy.

Note that if $$b=0$$ then both of these strategies revert back to the zero expectation of a fair coin toss. If there is the slightest bias however, then using these strategies will allow you to potentialy profit from it. I say potentially because if the bias is very small then you can expect large deviations from the expectation.

The majority rule strategy actually goes against what is known as the gambler's fallacy. This is a belief by many gamblers that if a fair coin comes up heads more often than tails then the probability of tails has increased. Not only is this wrong from the standpoint of the coin not having any memory but you can never really be sure that a coin is fair. So why not bet as though there may be a potential bias?

I once met a craps player in Las Vegas who showed me a large notebook that had the results of thousands of dice rolls in craps games. He had spent years meticulously recording this data and was convinced that it showed the gambler's fallacy was true. This brings up the question of how to extend the coin results to dice. I will probably do this in some future post.

I should also mention that the majority rule only works well if the bias never switches sides. For a physical coin the bias will almost certainly remain constant unless there is a change in the way it's tossed. For something like daily returns in the stock market it is possible for the bias to change. A string of high probability positive returns can be followed by a string of high probability negative returns. In this case using the strategy of betting the same as the previous toss may be better than the majority rule. This gives some credence to the trend following strategies used by some traders in the market.

It is possible to devise more sophisticated strategies for the case of a non-constant bias. This gets into the subject of Markov models, possibly another future post.

The following reference talks about the previous toss betting strategy.

A strategy that exploits (unknown) bias in tossing a real coin, Stephen J. Royle, The Mathematical Scientist, Issue 34.1, June 2009, p.30-33.

© 2010-2012 Stefan Hollos and Richard Hollos