## The Mysterious Coin

A forum for good logic/math puzzles.

Moderators: jestingrabbit, Moderators General, Prelates

gaga654
Posts: 12
Joined: Tue Mar 01, 2011 1:37 am UTC

### The Mysterious Coin

Suppose you have a standard coin with a head on one side and a tail on the other. However, you don't know the probability the coin will land on heads - it could be anywhere from 0 to 1. Because any probability is equally likely, the overall probability that you will get a heads when tossing the coin is 1/2. Now, suppose you toss the coin once and it lands on heads. What is the probability that it will land heads if you toss it again?

brynerd
Posts: 1
Joined: Wed Jun 08, 2011 1:18 am UTC

### Re: The Mysterious Coin

P(Head|Head)= .50; coin tosses are independent events, meaning that the outcome of one coin toss (event) does not affect the outcome of another.

futurityverb
Posts: 7
Joined: Wed Apr 27, 2011 4:49 am UTC

### Re: The Mysterious Coin

Spoiler:
1/2 ? Landing on heads once doesn't change the likelihood of it landing on heads on a subsequent flip, right? I'm bad at these.

gaga654
Posts: 12
Joined: Tue Mar 01, 2011 1:37 am UTC

### Re: The Mysterious Coin

I may be wrong, but I think that's incorrect, and here's why:
Spoiler:
Assume that the coin must land on heads on a probability of 0, 1/2, or 1. Then, given that it landed heads, there is a 2/3 chance that it lands on heads with probability 1, and a 1/3 chance that it lands on heads with probablility 1/2, giving it an overall chance of 5/6 for landing on heads the next time. I believe that similar reasoning will hold if the coin can land on heads with any probability.

Qaanol
The Cheshirest Catamount
Posts: 3060
Joined: Sat May 09, 2009 11:55 pm UTC

### Re: The Mysterious Coin

gaga654 wrote:Suppose you have a standard coin with a head on one side and a tail on the other. However, you don't know the probability the coin will land on heads - it could be anywhere from 0 to 1. Because any probability is equally likely, the overall probability that you will get a heads when tossing the coin is 1/2. Now, suppose you toss the coin once and it lands on heads. What is the probability that it will land heads if you toss it again?

I bolded the part that’s false.

But assuming it were true, the answer would be

Spoiler:
[imath]⅔[/imath]

On the other hand, assuming the much more likely situation that, when I first encounter “a standard coin” my prior probability for it is a sharp spike around 1/2, then futurityverb is essentially correct. At least, each individual datum has far less of an impact on my prior distribution for it.
wee free kings

phlip
Restorer of Worlds
Posts: 7556
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

### Re: The Mysterious Coin

Yay, Bayes' theorem...
Spoiler:
Working with a continuous probability... say the probability that a given coin flip is heads is p, where p is an unknown value with a prior uniformly distributed between 0 and 1. We then toss the coin and get a heads. What is our new probability function for p?

Well, we can find the new cdf directly from Bayes. For any x in [0,1], P(p <= x) = x (this is our prior). P(heads) is 1/2, P(heads | p <= x) is x/2, both again based on the uniform prior. So P(p <= x | heads) = P(heads | p <= x)P(p <= x)/P(heads) = (x/2)*x/(1/2) = x2. So our posterior pdf is the derivative of this - P(x) = 2x.

The probability of our next throw being heads is the sum of P(x)*x (there's a P(x) chance that p=x, and if so, the chance that the coin will land heads again is x), ie the integral from 0 to 1 of P(x)x dx, which comes out as 2/3.

But yes, that's taking the uniform prior as a given... in real life, with a real coin, that's not a reasonable prior, so you'd have a different result.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

gaga654
Posts: 12
Joined: Tue Mar 01, 2011 1:37 am UTC

### Re: The Mysterious Coin

I realize that in real life it would not be equally likely to have any probability, but for the sake of this problem assume that it is. I don't know what the actual answer is, but I believe that phlip and Qaanol are correct.

Qaanol
The Cheshirest Catamount
Posts: 3060
Joined: Sat May 09, 2009 11:55 pm UTC

### Re: The Mysterious Coin

Follow-up question:

Again starting from a uniform prior, how many times in a row must the coin land on heads (without ever landing on tails) before you are 95% confident that the coin is not fair (ie. that the true odds are not 50-50)?
wee free kings

phlip
Restorer of Worlds
Posts: 7556
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

### Re: The Mysterious Coin

Qaanol wrote:Follow-up question:

Again starting from a uniform prior, how many times in a row must the coin land on heads (without ever landing on tails) before you are 95% confident that the coin is not fair (ie. that the true odds are not 50-50)?

Spoiler:
None, as a uniform prior already has it almost-certain that the probability is not 50/50.

You're going to want to specify a confidence interval, not just confidence at a point, because that's always going to be 0 unless you have a prior with nonzero point probabilities somewhere.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

Qaanol
The Cheshirest Catamount
Posts: 3060
Joined: Sat May 09, 2009 11:55 pm UTC

### Re: The Mysterious Coin

phlip wrote:
Qaanol wrote:Follow-up question:

Again starting from a uniform prior, how many times in a row must the coin land on heads (without ever landing on tails) before you are 95% confident that the coin is not fair (ie. that the true odds are not 50-50)?

Spoiler:
None, as a uniform prior already has it almost-certain that the probability is not 50/50.

You're going to want to specify a confidence interval, not just confidence at a point, because that's always going to be 0 unless you have a prior with nonzero point probabilities somewhere.

Ahem. How many times must the coin land on heads without landing on tails before you are 95% confident that the coin is biased in favor of heads?
wee free kings

sfwc
Posts: 224
Joined: Tue Mar 29, 2011 1:41 pm UTC

### Re: The Mysterious Coin

Qaanol wrote:How many times must the coin land on heads without landing on tails before you are 95% confident that the coin is biased in favor of heads?
Spoiler:
Call the actual probability of the coin landing on heads p. The chance of the coin landing heads k consecutive times is 1/(k+1), but the chance of this happening if p is at most 1/2 is 1/(k+1) * 1/2k. Of course, the prior chance that p is at most 1/2 is just 1/2. So by Bayes' theorem the chance that the coin isn't biased towards heads given that we've seen it land heads k consecutive times is 1/2 * 1/(k+1) * 1/2k * (k+1) = 1/2k+1. We want this to be at most 5%, or 1/20. So we should take k = 4. That is, the coin must land on heads 4 consecutive times before we are 95% confident it is biased in favour of heads.
Note that we need far more consecutive heads (18) before we become 95% confident that the next time we toss the coin it will again land on heads.

ARandomDude
Posts: 60
Joined: Mon Dec 28, 2009 7:10 pm UTC

### Re: The Mysterious Coin

As a side note, it's bad statistical procedure to generate a confidence interval without at least 5-10 of both observations.

theodds
Posts: 23
Joined: Sat Jun 04, 2011 3:30 pm UTC

### Re: The Mysterious Coin

ARandomDude wrote:As a side note, it's bad statistical procedure to generate a confidence interval without at least 5-10 of both observations.

Nah, it's okay. This is only a problem if you are relying on (antiquated) approximations.

Spiky
Posts: 14
Joined: Thu Mar 10, 2011 5:24 am UTC

### Re: The Mysterious Coin

There is always a variable forgotten in the coin flip questions. And that is how the coin is flipped.

I was bored one month in my teens and practiced flipping coins. A standard USA nickel makes a perfect flipper if you want to destroy any probabilities (or win bets), surprisingly better than the quarter, at least for me. Learn to flip uniformly and you can flip/predict with near 100% accuracy. Just like shooting free throws, all it takes is practice. I believe I stopped after 28 tails in a row once I learned to flip, and I could predict more than that. Then I was bored with that, moved on.

Posts: 1267
Joined: Thu Jun 16, 2011 6:36 pm UTC

### Re: The Mysterious Coin

Spiky wrote:Learn to flip uniformly and you can flip/predict with near 100% accuracy.

That has got to be the most useful skill EVER. Holy crap.

jaap
Posts: 2085
Joined: Fri Jul 06, 2007 7:06 am UTC
Contact:

### Re: The Mysterious Coin

Spiky wrote:Learn to flip uniformly and you can flip/predict with near 100% accuracy.

That has got to be the most useful skill EVER. Holy crap.

Here's a video of me doing just this. If I had no skill, I would have expected to need about 512 recording attempts to get ten heads in a row, but I think this was the third or fourth try.

Dason
Posts: 1310
Joined: Wed Dec 02, 2009 7:06 am UTC
Location: ~/

### Re: The Mysterious Coin

It's also REALLY easy if you're allowed to catch it in one hand then put it on the back of your other. The reason being that it's relatively easy to run your thumb against the side of a quarter and tell if you're rubbing either heads or tails. Then it's just a matter of flipping it without being caught which is pretty easy to do as well.

If you're having somebody else call it and you want to make it land opposite of what they call it doesn't help you much if the other person calls it after you flip it and put it on your wrist so you really do need them to "call it in the air".
double epsilon = -.0000001;

tomtom2357
Posts: 563
Joined: Tue Jul 27, 2010 8:48 am UTC

### Re: The Mysterious Coin

I have a problem, assuming uniform prior you flip the coin and it comes up heads three times and tails once, what is the probability that on the next toss it will come up heads?
I have discovered a truly marvelous proof of this, which this margin is too narrow to contain.

campboy
Posts: 52
Joined: Wed Jun 18, 2008 1:54 am UTC

### Re: The Mysterious Coin

tomtom2357 wrote:I have a problem, assuming uniform prior you flip the coin and it comes up heads three times and tails once, what is the probability that on the next toss it will come up heads?

If you flip a+b times and get a heads and b tails the probability of a head on the next go is
Spoiler:
$\frac{\int_0^1p^{a+1}(1-p)^b\mathrm{d}p}{\int_0^1p^a(1-p)^b\mathrm{d}p}$

which for a=3, b=1 gives
Spoiler:
2/3.

tomtom2357
Posts: 563
Joined: Tue Jul 27, 2010 8:48 am UTC

### Re: The Mysterious Coin

Can you solve those integrals please?
I have discovered a truly marvelous proof of this, which this margin is too narrow to contain.

RonWessels
Posts: 43
Joined: Tue Aug 24, 2010 8:40 pm UTC
Location: Mississauga, ON, CA

### Re: The Mysterious Coin

tomtom2357 wrote:Can you solve those integrals please?
Spoiler:
$\frac{\int_0^1p^{a+1}(1-p)^b\mathrm{d}p}{\int_0^1p^a(1-p)^b\mathrm{d}p}$
$= \frac{\int_0^1p^{3+1}(1-p)^1\mathrm{d}p}{\int_0^1p^3(1-p)^1\mathrm{d}p}$
$= \frac{\int_0^1(p^4 - p^5)\mathrm{d}p}{\int_0^1(p^3 - p^4)\mathrm{d}p}$
$= \frac{[\frac{1}{5}p^5 - \frac{1}{6}p^6]_0^1}{[\frac{1}{4}p^4 - \frac{1}{5}p^5]_0^1}$
$= \frac{\frac{1}{5} - \frac{1}{6}}{\frac{1}{4} - \frac{1}{5}}$
$= \frac{2}{3}$

tomtom2357
Posts: 563
Joined: Tue Jul 27, 2010 8:48 am UTC

### Re: The Mysterious Coin

I mean a general solution.
I have discovered a truly marvelous proof of this, which this margin is too narrow to contain.

phlip
Restorer of Worlds
Posts: 7556
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

### Re: The Mysterious Coin

I'm sure you could write out a general form... they're just integrals of polynomials, after all. But you'd have to expand the binomial out, and you'd end up with something much uglier and less usable than the original integral form.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

tomtom2357
Posts: 563
Joined: Tue Jul 27, 2010 8:48 am UTC

### Re: The Mysterious Coin

Okay, I guess that I can work with the integral. Also, I have an interesting problem, I have a strange coin, in that for the first coin toss, is is 50-50 to land on heads or tails, but on every toss after that, the coin has a 75% chance of landing on the face it landed on last time. What is the distribution of the tosses now (e.x. a normal coin has a binomial distribution, which tends to a normal distribution as the amount of tosses approaches infinity)
I have discovered a truly marvelous proof of this, which this margin is too narrow to contain.

mfb
Posts: 947
Joined: Thu Jan 08, 2009 7:48 pm UTC

### Re: The Mysterious Coin

It still converges to the binomial distribution (but with a different variance) and to the normal distribution (again with a different variance), but you see larger deviations from the distribution for small numbers of coin tosses.

To calculate, you can describe the system with two distributions together: one for "last toss was head" and one for "last toss was tail".

tomtom2357
Posts: 563
Joined: Tue Jul 27, 2010 8:48 am UTC

### Re: The Mysterious Coin

Are you sure? When I tried it for small numbers of tosses, it looked like there was a sudden dip in the distribution at about the center.
I have discovered a truly marvelous proof of this, which this margin is too narrow to contain.

gmalivuk
GNU Terry Pratchett
Posts: 26518
Joined: Wed Feb 28, 2007 6:02 pm UTC
Location: Here and There
Contact:

### Re: The Mysterious Coin

tomtom2357 wrote:Are you sure? When I tried it for small numbers of tosses, it looked like there was a sudden dip in the distribution at about the center.
That in no way precludes eventual *convergence* to distributions without such a dip.
Unless stated otherwise, I do not care whether a statement, by itself, constitutes a persuasive political argument. I care whether it's true.
---
If this post has math that doesn't work for you, use TeX the World for Firefox or Chrome

(he/him/his)

tomtom2357
Posts: 563
Joined: Tue Jul 27, 2010 8:48 am UTC

### Re: The Mysterious Coin

Okay then, could you graph the distribution then and show me?
I have discovered a truly marvelous proof of this, which this margin is too narrow to contain.

gmalivuk
GNU Terry Pratchett
Posts: 26518
Joined: Wed Feb 28, 2007 6:02 pm UTC
Location: Here and There
Contact:

### Re: The Mysterious Coin

Try doing it yourself. You'll learn more than if you constantly expect everyone else to prove things for you.
Unless stated otherwise, I do not care whether a statement, by itself, constitutes a persuasive political argument. I care whether it's true.
---
If this post has math that doesn't work for you, use TeX the World for Firefox or Chrome

(he/him/his)

Dason
Posts: 1310
Joined: Wed Dec 02, 2009 7:06 am UTC
Location: ~/

### Re: The Mysterious Coin

phlip wrote:I'm sure you could write out a general form... they're just integrals of polynomials, after all. But you'd have to expand the binomial out, and you'd end up with something much uglier and less usable than the original integral form.

Actually I think you can get a nice form in terms of factorials if you restrict a and b to be integers.
double epsilon = -.0000001;

Macbi
Posts: 941
Joined: Mon Apr 09, 2007 8:32 am UTC
Location: UKvia

### Re: The Mysterious Coin

Indigo is a lie.
Which idiot decided that websites can't go within 4cm of the edge of the screen?
There should be a null word, for the question "Is anybody there?" and to see if microphones are on.

tomtom2357
Posts: 563
Joined: Tue Jul 27, 2010 8:48 am UTC

### Re: The Mysterious Coin

I think that macbi just killed the thread.
I have discovered a truly marvelous proof of this, which this margin is too narrow to contain.

tomtom2357
Posts: 563
Joined: Tue Jul 27, 2010 8:48 am UTC

### Re: The Mysterious Coin

Wait, so the actual solution is a/b, or a+1/b+2?
I have discovered a truly marvelous proof of this, which this margin is too narrow to contain.

jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

### Re: The Mysterious Coin

tomtom2357 wrote:Wait, so the actual solution is a/b, or a+1/b+2?

ameretrifle wrote:Magic space feudalism is therefore a viable idea.

ybot968
Posts: 11
Joined: Tue Sep 15, 2015 9:42 pm UTC

### Re: The Mysterious Coin

Supose you have got an special skill to detect a defective coin before the first flip.

You make a prior, probably a 60-40 distribution in favour to heads.

You start testing

As you are a bayesian man, you rely on your prior , a 60-40 frequency in your next 200 tosses might mean money to you

A frequestist needs more data

How much data takes to know the accurate frequency?

### Who is online

Users browsing this forum: No registered users and 4 guests