Open Side Menu Go to the Top
Register
coin toss game coin toss game

01-13-2019 , 10:40 AM
You have a biased coin and a $20 bankroll. You can toss the coin 10 times and wager as much as you want of your bankroll on any toss, paying even money if you guess right. What's your strategy?
coin toss game Quote
01-13-2019 , 11:14 AM
When you say "biased coin", are you basically saying it's a foul coin but we don't know if it's heads/heads or tails/tails? Do we even know it's a foul coin or is an assumption of this game that we have to flip the coin a certain a number of times before we could be sure it's not fair? Could you clarify the parameters a bit here?
coin toss game Quote
01-13-2019 , 11:31 AM
0% < P(Heads) < 100%

P(Tails) = 1 - P(Heads)

P(Heads) != P(Tails)
coin toss game Quote
01-13-2019 , 12:55 PM
So you know it's biased, but you don't know which side is favored nor how large the bias is?

Then the 1st flip is 50% and you minbet (which I guess is a penny).

On each subsequent flip, use Bayes* to update the probability and use Kelly to size your bet (unless your name is David Sklansky, in which case go all in).

*But the prior distribution is uniform, which means we can use MLE.

I'll probably give this a try another time.

Edit - I was talking about maximizing growth, but maximizing EV would be easy and you wouldn't need estimates. Minbet if the score is tied, else bet all-in on whichever side landed more times.

Last edited by heehaww; 01-13-2019 at 01:04 PM.
coin toss game Quote
01-13-2019 , 04:59 PM
Quote:
Originally Posted by heehaww
*But the prior distribution is uniform, which means we can use MLE.
Poor assumption
coin toss game Quote
01-14-2019 , 01:40 PM
Thinking off the cuff,: I don't really know yet how I'd approach this from a technical perspective but I'll guess the correct answer is going to be way more conservative than most guess. Not a whole lot of information I can use to update my priors.
coin toss game Quote
01-14-2019 , 01:49 PM
Also "people don't like to hand you free money" seems like a pretty good piece of information to use when adjusting priors.
coin toss game Quote
01-14-2019 , 01:57 PM
Quote:
Originally Posted by JoeC2012
Also "people don't like to hand you free money" seems like a pretty good piece of information to use when adjusting priors.
Agree. But these imaginary guys are handing you at least 20 bucks.

Also it's a theoretical brain teaser on a probability forum on the internet, not a real game a street hustler is offering so adjust priors based on that.
coin toss game Quote
01-14-2019 , 03:31 PM
Quote:
Originally Posted by stinkypete
Agree. But these imaginary guys are handing you at least 20 bucks.

Also it's a theoretical brain teaser on a probability forum on the internet, not a real game a street hustler is offering so adjust priors based on that.
Ok, you weren't going for the point I thought you were going for here. Disregard all my posts above

If this is a purely technical question, I have no formal Bayesian training so this may be over my head but I'll take a stab.

1. Since I have no information other than what you posted above, I don't see anything I can assume other than that every value of p(heads) where 0 < p(heads) < 1 other than p(heads)=0.5 is equally likely. This is the part of the solution I feel really shaky about, think I might be making the same mistake heehaww did, but I can't think of any other way to assume a distribution. Hope someone else can chime in if I've got this wrong. Of course we minbet for the first flip.

2. If the first flip comes up heads, given the assumed distribution from (1), we can now update priors, now assuming that p(heads)=0.99 is 99x more likely than p(heads)=0.01. I think it's clear why this is the case but I can elaborate if necessary. This means when the first flip comes up heads, our new estimate of p(heads)=2/3, and so the Kelly is now 1/3.

3. We keep updating priors accordingly. From a practical perspective, sometimes actual p(heads)=0.52 and we mistake a bunch of noise for signal and bet way above the real Kelly, but sometimes we run pure and the real p(heads)=0.96 and we make an assload.
coin toss game Quote
01-14-2019 , 03:33 PM
Just realized my previous post ignored the ramifications of the fact we can only flip 10 times rather than keep flipping indefinitely, gonna have to stew on that one for a bit.
coin toss game Quote
01-14-2019 , 03:56 PM
Quote:
Originally Posted by JoeC2012
Just realized my previous post ignored the ramifications of the fact we can only flip 10 times rather than keep flipping indefinitely, gonna have to stew on that one for a bit.
Ya, thinking more, Kelly serves as a lower bound for how much you should bet, but my revised answer is that you should bet something between Kelly and 100%, skewing more toward 100% as you get close to the end of the game. For instance if the first 9 flips come 6 heads and 3 tails it's a big leak to only bet Kelly on the 10th roll and you should probably go all in as long as the money isn't significant to your liferoll (and it rarely will be; I suspect it isn't a coincidence stinkypete set up this hypothetical with a $20 bankroll rather than a $10k one).
coin toss game Quote
01-14-2019 , 04:48 PM
Quote:
Originally Posted by JoeC2012
Ya, thinking more, Kelly serves as a lower bound for how much you should bet, but my revised answer is that you should bet something between Kelly and 100%, skewing more toward 100% as you get close to the end of the game. For instance if the first 9 flips come 6 heads and 3 tails it's a big leak to only bet Kelly on the 10th roll and you should probably go all in as long as the money isn't significant to your liferoll (and it rarely will be; I suspect it isn't a coincidence stinkypete set up this hypothetical with a $20 bankroll rather than a $10k one).
To me the question is only interesting if it were an amount of money that were meaningful, so I'm presuming the outcome of the $20 bankroll matters by the end of the question. I'm not a math guru so I don't have any answer that matters but I'd just make loose approximations of what felt correct considering information given, risk of ruin etc. My bet sizes would definitely get much larger or controlled/strategic towards the end of the sequence than the beginning of the sequence.

If it were just $20 or something insignificant, I'd just min-bet round one, then just all-in on whichever side has the highest frequency or min-bet if they wound up tied again in the sequence..
coin toss game Quote
01-14-2019 , 06:04 PM
Quote:
Originally Posted by theskillzdatklls
To me the question is only interesting if it were an amount of money that were meaningful, so I'm presuming the outcome of the $20 bankroll matters by the end of the question. I'm not a math guru so I don't have any answer that matters but I'd just make loose approximations of what felt correct considering information given, risk of ruin etc. My bet sizes would definitely get much larger or controlled/strategic towards the end of the sequence than the beginning of the sequence.

If it were just $20 or something insignificant, I'd just min-bet round one, then just all-in on whichever side has the highest frequency or min-bet if they wound up tied again in the sequence..
Yup, as long as you're not super busto this should be fine or a very small mistake.
coin toss game Quote
01-14-2019 , 06:24 PM
Quote:
Originally Posted by JoeC2012
1. Since I have no information other than what you posted above, I don't see anything I can assume other than that every value of p(heads) where 0 < p(heads) < 1 other than p(heads)=0.5 is equally likely. This is the part of the solution I feel really shaky about, think I might be making the same mistake heehaww did, but I can't think of any other way to assume a distribution. Hope someone else can chime in if I've got this wrong. Of course we minbet for the first flip.
You can't take that assumption as fact, but it's a reasonable thing to do if you want to start seeing how the game plays out when you develop strategies based on that assumption. One of the keys to this problem is that we do *not* know and cannot assume anything about how fair the coin is, except that it's not fair.

Quote:
2. If the first flip comes up heads, given the assumed distribution from (1), we can now update priors, now assuming that p(heads)=0.99 is 99x more likely than p(heads)=0.01. I think it's clear why this is the case but I can elaborate if necessary. This means when the first flip comes up heads, our new estimate of p(heads)=2/3, and so the Kelly is now 1/3.
We don't actually need the assumption from 1 to know that P(F1) = 0.99 is 99x more likely than P(F1) = 0.01 (where F1 is the result of the first flip) as long as we assume the prior distribution is symmetrical, ie. it's equally likely to be biased heads or tails and to the same degree. (I didn't explicitly state that, but it's a fair default assumption.)
coin toss game Quote
01-14-2019 , 06:29 PM
Quote:
Originally Posted by JoeC2012
3. We keep updating priors accordingly. From a practical perspective, sometimes actual p(heads)=0.52 and we mistake a bunch of noise for signal and bet way above the real Kelly, but sometimes we run pure and the real p(heads)=0.96 and we make an assload.
Quote:
Originally Posted by JoeC2012
Ya, thinking more, Kelly serves as a lower bound for how much you should bet, but my revised answer is that you should bet something between Kelly and 100%, skewing more toward 100% as you get close to the end of the game. For instance if the first 9 flips come 6 heads and 3 tails it's a big leak to only bet Kelly on the 10th roll and you should probably go all in as long as the money isn't significant to your liferoll (and it rarely will be; I suspect it isn't a coincidence stinkypete set up this hypothetical with a $20 bankroll rather than a $10k one).
Correct that $20 was chosen intentionally. I think it's a good number for the general population, but in hindsight I think a better number for a gambling forum would have been $100-$200.

Re: the situation where P(h) = 0.52, do we really care about that situation? Given that the question is being asked, I think it's fair to assume there's a >>0 chance the theoretical coin is *significantly* biased and nearly all our EV is in the situations where that is the case.
coin toss game Quote
01-14-2019 , 06:37 PM
Quote:
Originally Posted by theskillzdatklls
If it were just $20 or something insignificant, I'd just min-bet round one, then just all-in on whichever side has the highest frequency or min-bet if they wound up tied again in the sequence..
Not saying that's a bad strategy, but you're making it sound more complicated than it is. That simplifies to "bet all-in on rolls 2-10 on the result of the first flip."
coin toss game Quote
01-15-2019 , 11:48 PM
Before betting, I'd register a "meaningful" series of patterns giving me a kind of statistical evidence, as a biased coin will present more singles on one side than streaks, more doubles than 3+ streaks, etc.

To be confident I'm betting the right side, I'll wait a sigma of at least 2.5 to make a bet as an asymmetrical proposition will very rarely overcome such sd value, of course splitting the probability on each different classes considered.
coin toss game Quote
01-15-2019 , 11:55 PM
Quote:
Originally Posted by asymbacguy
Before betting, I'd register a "meaningful" series of patterns giving me a kind of statistical evidence, as a biased coin will present more singles on one side than streaks, more doubles than 3+ streaks, etc.



To be confident I'm betting the right side, I'll wait a sigma of at least 2.5 to make a bet as an asymmetrical proposition will very rarely overcome such sd value, of course splitting the probability on each different classes considered.
You only get 10 rolls
coin toss game Quote
01-16-2019 , 02:19 AM
Quote:
Originally Posted by heehaww

*But the prior distribution is uniform, which means we can use MLE.
Quote:
Originally Posted by stinkypete
Poor assumption
?????

That isn't an assumption. If you have no information, the prior distribution is uniform.
coin toss game Quote
01-16-2019 , 06:55 AM
Quote:
Originally Posted by RR
?????



That isn't an assumption. If you have no information, the prior distribution is uniform.
?????

It's a huge assumption.
coin toss game Quote
01-17-2019 , 01:02 AM
Spoiler:
If both sides have shown up equally as often, then bet zero.

Else, find the ordered-tuple for the two counts in this matrix:
Code:
        1       2       3       4       5       6       7       8       9
0      1/3     1/2     3/5     2/3     5/7     3/4     7/9     4/5     9/11    
1              1/5     1/3     3/7     1/2     5/9     3/5     7/11    
2                      1/7     1/4     1/3     2/5     5/11    
3                              1/9     1/5     3/11    
4                                      1/11
and bet that fraction of your bankroll on the side which has shown up most often.

eg:

{#Heads = 6, #Tails = 2} --> bet 2/5th of your bankroll on heads.
{#Tails = 1, #Heads = 0} --> bet 1/3rd of your bankroll on tails.
{#Heads = 5, #Tails = 4} --> bet 1/11th of your bankroll on heads.

Method:
Spoiler:
Exactly what heehaww suggested (using a beta distribution with a uniform (1,1) prior).

Mathematica code:
Code:
For[b = 0, b <= 9, b++,
 For[a = b + 1, a <= 9 - b, a++,
  Print[a]; Print[b]; Print[Solve[D[Integrate[PDF[BetaDistribution[1 + a, 1 + b], x]*(x*Log[1 + f] + (1 - x)*Log[1 - f]), {x, 0, 1}], f] == 0, f]]
  ]
 ]




Juk

Last edited by jukofyork; 01-17-2019 at 01:19 AM. Reason: Fixed table
coin toss game Quote
01-17-2019 , 02:10 AM
That's a fair answer for an infinitely repeatable game but you're throwing away far too much EV betting 9/11 on the final round after 9 heads, or 4/5 on the 9th round after 8 heads... and so on
coin toss game Quote
01-17-2019 , 08:03 AM
Quote:
Originally Posted by stinkypete
That's a fair answer for an infinitely repeatable game but you're throwing away far too much EV betting 9/11 on the final round after 9 heads, or 4/5 on the 9th round after 8 heads... and so on
Spoiler:
Yeah, you're right.

So this matrix would attempt to grow your bankroll at the fastest possible rate on flips 1-9, then maximise the expected value of the final amount by betting all-in on the last flip:
Code:
        1       2       3       4       5       6       7       8       9
0      1/3     1/2     3/5     2/3     5/7     3/4     7/9     4/5      1    
1              1/5     1/3     3/7     1/2     5/9     3/5      1
2                      1/7     1/4     1/3     2/5      1
3                              1/9     1/5      1
4                                       1

Juk
coin toss game Quote
01-17-2019 , 01:27 PM
Spoiler:
OK so I played round with this some more and it seems the best strategy is just to bet 100% of your bankroll whenever you have an advantage bet:

Code:
#include <iostream>
#include <random>
#include <cmath>
#include <ctime>
#include <algorithm>

// The number of simulations to run.
//const int NUM_SIMS = 100000000;
const int NUM_SIMS = 5000000;		// The largest value that will run using http://cpp.sh/.

// The "Greedy" strategy (ie: always bet full bankroll when advantage bet presents itself).
const std::vector<std::vector<double>> GREEDY_STRATEGY {
	{0.0,	1.0,	1.0,	1.0,	1.0,	1.0,	1.0,	1.0,	1.0,	1.0},
	{0.0,	0.0,	1.0,	1.0,	1.0,	1.0,	1.0,	1.0,	1.0,	0.0},
	{0.0,	0.0,	0.0,	1.0,	1.0,	1.0,	1.0,	1.0,	0.0,	0.0},
	{0.0,	0.0,	0.0,	0.0,	1.0,	1.0,	1.0,	0.0,	0.0,	0.0},
	{0.0,	0.0,	0.0,	0.0,	0.0,	1.0,	0.0,	0.0,	0.0,	0.0}
};

// The "Kelly" strategy.
const std::vector<std::vector<double>> KELLY_STRATEGY {
	{0.0,		1.0/3.0,	1.0/2.0,	3.0/5.0,	2.0/3.0,	5.0/7.0,	3.0/4.0,	7.0/9.0,	4.0/5.0,	1.0},
	{0.0,		0.0,		1.0/5.0,	1.0/3.0,	3.0/7.0,	1.0/2.0,	5.0/9.0,	3.0/5.0,	1.0,		0.0},
	{0.0,		0.0,		0.0,		1.0/7.0,	1.0/4.0,	1.0/3.0,	2.0/5.0,	1.0,		0.0,		0.0},
	{0.0,		0.0,		0.0,		0.0,		1.0/9.0,	1.0/5.0,	1.0,		0.0,		0.0,		0.0},
	{0.0,		0.0,		0.0,		0.0,		0.0,		1.0,		0.0,		0.0,		0.0,		0.0}
};

double score(const std::vector<std::vector<double>>& strategy)
{
	// Random number generator to use.
	std::mt19937 generator(time(nullptr));

	// Distribution for the coin bias.
	std::uniform_real_distribution<double> biasDistribution(0.0,1.0);

	// Sum of bankroll over all sims,
	double sumBankroll=0.0;

	// Run lots of times with different bias values.
	for (int i=0;i<NUM_SIMS;i++) {

		// Generate a random bias for the coin.
		double bias=biasDistribution(generator);

		// Distribution for the coin-flips.
		std::bernoulli_distribution coinDistribution(bias);

		// Start off with $20.
		double currentBankroll=20.0;

		// Run a single game.
		int numHeads=0;
		int numTails=0;
		for (int i=0;i<10;i++) {

			// Work out the bet fraction the strategy says we should do.
			double betFraction=0.0;
			if (numHeads>numTails)
				betFraction=strategy[numTails][numHeads];
			else if (numHeads<numTails)
				betFraction=(-strategy[numHeads][numTails]);

			// Generate a random coin toss and update the counts/bankroll.
			if(coinDistribution(generator)) {
				numHeads++;
				currentBankroll*=(1.0+betFraction);
			}
			else {
				numTails++;
				currentBankroll*=(1.0-betFraction);
			}

		}

		// Add to the sum of bankroll.
		sumBankroll+=currentBankroll;

	}

	// Return the average EV per game.
	return (sumBankroll/static_cast<double>(NUM_SIMS)-20.0);

}

int main() {
	std::cout << "Greedy strategy = $" << score(GREEDY_STRATEGY) << " EV per game" << std::endl;
	std::cout << "Kelly strategy  = $" << score(KELLY_STRATEGY) << " EV per game" << std::endl;
}
To run just copy into http://cpp.sh/ and hit run (and reduce the NUM_SIMS if you get no output).

Results:

Code:
Greedy strategy = $1841.38 EV per game
Kelly strategy  = $402.782 EV per game
I guess it's possible that there is a bug in the sim or the mathematica code, but I've looked over them both a few times and can't see anything wrong.

-------------------------------

EDIT: Just noticed heehaww posted this earlier:
Quote:
Originally Posted by heehaww
Edit - I was talking about maximizing growth, but maximizing EV would be easy and you wouldn't need estimates. Minbet if the score is tied, else bet all-in on whichever side landed more times.

Juk

Last edited by jukofyork; 01-17-2019 at 01:40 PM.
coin toss game Quote
01-17-2019 , 02:03 PM
Just in case anybody is still interested, I worked out how to get mathematica to compute the general solution (using a Beta (1,1) prior):

Code:
Assuming[{{h, t} \[Element] Integers, h >= 0 && t >= 0}, Solve[D[Integrate[PDF[BetaDistribution[1 + h, 1 + t], x]*(x*Log[1 + f] + (1 - x)*Log[1 - f]), {x, 0, 1}], f] == 0, f]]
Code:
f = (h-t)/(2+h+t)
So the Kelly fraction (if this were an infinitely repeatable game) = difference in counts / (total number of flips + 2)

Juk
coin toss game Quote

      
m