Wednesday, 3 July 2024

Magical coin

Magical coin

setup

You are traveling home on a gloomy night in the dead of winter. You clutch the edge of your cloak with your frozen fingers, hoping to protect yourself from the hailstorm. Suddenly, a shadowy figure blocks your path. It speaks to you in a low, crackling tone.
“Could I interest you in a magical coin?”
You try to ignore the figure and continue walking, but it stops you.
“Don’t be rude, at least take a look at it.”
You are to tired to argue, so you sigh, and decide to humour the creature. “What does the coin do?” you ask. “What makes it magical?”
The creature grins, revealing a row of crooked teeth. “Whenever you play any game —any game at all— decided by flipping this coin, you have a fifty-five percent chance of winning.”
“Why would I want this?” I frown. “For one dollar, I can buy a coin with heads on both sides. That gives me a one hundred percent chance. This coin is similar but worse.”
The creature chuckles. “To a simple mind, maybe, but a smart man like you should be able to see this coin’s limitless potential.”

How the coin breaks reality

On first glance, the coin appears to be practically useless, or at least as useful as a slightly rigged coin. However, the shadowy figure did claim that the coin was powerful. So the first question we can ask ourselves is, “Is there anything we can do with the magic coin that we can not do with the double-headed coin?”

This answer is easy: “What if we need tails to win?” In other words, “What if we, as the ‘player,’ are not allowed to decide which option (heads or tails) is winning?”

This isn’t reality-breaking yet. With a little practice, a human can consistently throw and catch a coin in exactly the same way. The outcome of the coin flip is only determined by how you hold the coin before flipping. So depending on whether you need heads or tails to win, you just hold the coin differently. It is hard to do it one hundred percent consistently, but beating the fifty-five-percent odds is perfectly doable.

The second question we ask ourselves is, “How does our magical coin differ from this slight-of-hand trick?” What can our magical coin do that the slight-of-hand coin cannot?"

The solution is straight-forward. What if the game is set up in such a way that we do not know whether heads or tails are winning.

Imagine the following game:

Let’s flip a coin. Tomorrow, we will check the lottery results to see if the number 1 was drawn. If so, heads wins. If not, tails wins.

For this game, the rigged coin and the trick do not help (in a way they do, cause tails has a bigger chance of winning, so to maximize the winning chances, rig it to tails). But more importantly, we are not interested in winning this game, but more so in winning the lottery.

Knowing with 55% certainty that a number will appear in the lottery results is an advantage, probably, but we can do better.

We can play this game ninety-nine times and total the number of heads and tails. This is similar to drawing from a binomial distribution with unknown pp.

number of heads head is winning (p=0.55p=0.55) tail is winning (p=0.45p=0.45)
49\leq 49 16 % 84 %
50\geq 50 84 % 16 %

*Note: We chose 99 rather than 100 times because an odd number of coin flips prevents the number of heads and tails from tying.

This gives us an 84% chance of correctly predicting the lottery number.

If we repeat this for all 45 numbers, our chances of correctly predicting all numbers are 0.06%. Which is significantly higher than the 0.0000001% chance you typically have, but still disappointingly low.

We can slightly improve our chances by selecting the six highest numbers rather than 50 as a cut-off point. Doing this will give us a 5% chance of winning. We can improve this probability by increasing the number of coin flips. For example, flipping each number 200, 300, or 400 times results in 28, 59, and 80 percent, respectively.

But then again, do you want to spend five hours flipping a coin?

Rigging it even more

Let us take a look at this game:

Throw ten coins. You win if.

  1. all coins are heads and tomorrow’s lottery results includes a 1
    OR
  2. all coins are tails and tomorrow’s lottery results does not include a 1

As this is indeed a game “that is decided by flipping this coin,” we have a 55% chance to win. This means that the one winning sequence has a 55%55\% chance of failing, while all other sequences have a 45%1023\frac{45\%}{1023} chance.

Note

If you are not convinced that all losing sequences have the same chance of appearing, consider that a non-uniform distribution of losing sequences makes rigging even easier. This is because in our game, we can change the second option as follows:
2. All coins are [whichever sequence had the lowest chance of appearing in option 1] and tomorrow’s lottery results do not include a 1

So, we obtain the following distribution table:

number of heads result contains a 1 result does not contain a one
10 55 % 0.034 %
0 0.034 % 55 %
any other 44.976% 44.976%

Using Bayes’ theorem, if we get ten heads in a row, the probability that our result includes one is 99.3%. Similarly, if we get ten tails in a row, the probability that our result does not include one is also 99.3%.
However, we only have a 55.034% chance of actually getting a decisive result. This is not an issue. If we do not get a definitive answer, we can simply play the game again. On average, we have to play 1.81 games or toss 18 coins before we get our result.

We can improve this concept by changing it to the following game.

Toss a coin 50 times. You win if the coin flips spell out the winning lottery numbers for tomorrow in binary, followed by 14 heads, and lose otherwise.

This method requires only 50 coin tosses to reveal all six numbers, making it more efficient.

Adversarial coins

In the previous chapter, I assumed that if the game was already lost, the coin would have a 50/50 chance of coming up heads or tails. What if that is not true and the coin has an unknown chance of coming up heads or tails? Or worse, what if the shadowy figure actually was the devil and had given us an adversarial coin? A coin that, whenever a game is not decided by our flip, ends up on whichever side we do not want.

Before we actually design a game that fixes this loophole (and actually abuses the fact that this is unspecified), let’s take a look at this simpler self referencing coin game, using a non-magical coin.

Flip two coins.
You win if:

  1. you get heads two times , AND the chance of winning this game is larger than 70%.
    OR
  2. you get tails at least one time AND the chance of winning this game is lower or equal to 70%.

If you try to calculate this, you will quickly realize it is a paradox. If we assume the chance is lower than 70%, it will be 75%, leading to a contradiction. However, if we assume the chance is higher than 70%, it will be 25%, also leading to a contradiction.

So, lets build a game using this pattern.

Flip a rigged coin.
You win if

  1. the coin lands on heads AND The sun always had had a 100% chance of exploding in the next 5 seconds, independent of the result of the coin.
    OR
  2. The chance of winning was not 55%

Lets break this down. The chances depend on three parameters:

  1. itself
  2. whether or not the sun “had had a 100% chance of exploding in the next 5 seconds, independent of the result of the coin.”
  3. chance to toss heads (referred to as hh)

In table form:

sun explodes sun does not explode
p=0.55p=0.55 p=hp=h p=0p=0
p0.55p \neq 0.55 p=1p=1 p=1p=1

There remain two possibilities

  1. You win, independent of the sun and the coin.
  2. You have a 55% chance of winning, the coin has a 55% chance of landing on heads, and the sun has a 100% chance of exploding.

If you play this game with any coin, rigged or not, option one is clearly the outcome. But as the coin the devil gave us is defined to have a 55% chance of winning, the only way to resolve this option 2, which states: “The sun always had had a 100% chance of exploding in the next 5 seconds, independent of the result of the coin.”

Except it does not. Because the devil clearly stated “any game decided by this coin.” If option 2 is false, you automatically win. In other words, the game is not decided by the coin, so the 100% win chance does not violate the devil’s promise.

We can fix this issue by adding an extra condition.

Flip a rigged coin.
You win if

  1. the coin lands on heads AND The sun always had had a 100% chance of exploding in the next 5 seconds, independent of the result of the coin.
    OR
  2. the coin lands on heads AND The chance of winning was not 55%

In table from:

sun explodes sun does not explode
p=0.55p=0.55 p=hp=h p=0p=0
p0.55p \neq 0.55 p=hp=h p=hp=h

There remain two possibilities

  1. You win on heads. independent of the sun. The chance to win is anything but 55%.
  2. You have a 55% chance of winning, the coin has a 55% chance of landing on heads, and the sun has a 100% chance of exploding.

As both options imply the game is decided by the coin flip, the chance to win has to be 55%, which means only option 2 can be true.

Which can only mean the sun explodes with 100% certainty, independent of the actual result.

Back to winning the lottery

Sure, blowing up the sun is nice and all, but lets look back at how we can use this to win the lottery.

Consider the following game:

Toss a coin 50 times
You win if

  1. The coin spells out the winning lottery numbers in binary, followed by 14 times heads.
    AND
  2. The coin always had been rigged (with a 100% chance) such that it had a 45% chance to spell out the winning lottery numbers, followed by 14 tails.

Otherwise, you lose.

If the coin is not rigged as described, you will never win, which would violate the “55% chance to win” condition, so condition 2 must hold true.

This does not work for the same reasons stated above. If condition 2 does not hold, you will undoubtedly lose, indicating that the game is not decided by a coin flip.

We can fix that by always making it decided by coin flip.

Toss a coin 50 times
You win if
open parentheses (
The coin spells out the winning lottery numbers in binary, followed by 14 times heads.
AND
The coin always had been rigged (with a 100% chance) such that it had a 45% chance to spell out the winning lottery numbers, followed by 14 tails.
close parentheses )
OR
open parentheses (
The chance to win is not 55%
AND
Last coinflip is heads.
close parentheses )
Otherwise, you lose.

This will always spell out the winning lottery numbers, followed by either heads or tails.