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

Postby gaga654 » Wed Jun 08, 2011 12:39 am UTC

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

Postby brynerd » Wed Jun 08, 2011 1:24 am UTC

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

Postby futurityverb » Wed Jun 08, 2011 1:26 am UTC

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

Postby gaga654 » Wed Jun 08, 2011 1:34 am UTC

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.

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

Re: The Mysterious Coin

Postby Qaanol » Wed Jun 08, 2011 1:55 am UTC

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

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

Re: The Mysterious Coin

Postby phlip » Wed Jun 08, 2011 1:57 am UTC

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

Postby gaga654 » Wed Jun 08, 2011 7:14 pm UTC

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.

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

Re: The Mysterious Coin

Postby Qaanol » Wed Jun 08, 2011 9:36 pm UTC

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

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

Re: The Mysterious Coin

Postby phlip » Thu Jun 09, 2011 12:21 am UTC

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)?

169 answer:
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]

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

Re: The Mysterious Coin

Postby Qaanol » Thu Jun 09, 2011 12:30 am UTC

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)?

169 answer:
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

Postby sfwc » Thu Jun 09, 2011 9:46 am UTC

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

Postby ARandomDude » Tue Jun 14, 2011 2:41 pm UTC

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

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

Re: The Mysterious Coin

Postby theodds » Tue Jun 14, 2011 6:55 pm UTC

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


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

Postby Spiky » Wed Jun 29, 2011 3:13 am UTC

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.

User avatar
Adam H
Posts: 1267
Joined: Thu Jun 16, 2011 6:36 pm UTC

Re: The Mysterious Coin

Postby Adam H » Wed Jun 29, 2011 4:58 pm UTC

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.
-Adam

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

Re: The Mysterious Coin

Postby jaap » Thu Jun 30, 2011 3:31 am UTC

Adam H wrote:
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.

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

Re: The Mysterious Coin

Postby Dason » Mon Jul 04, 2011 3:34 pm UTC

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

Postby tomtom2357 » Wed Jan 04, 2012 8:45 am UTC

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

Postby campboy » Wed Jan 04, 2012 12:46 pm UTC

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:
[math]\frac{\int_0^1p^{a+1}(1-p)^b\mathrm{d}p}{\int_0^1p^a(1-p)^b\mathrm{d}p}[/math]

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

Postby tomtom2357 » Thu Jan 05, 2012 8:20 am UTC

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

Postby RonWessels » Thu Jan 05, 2012 3:55 pm UTC

tomtom2357 wrote:Can you solve those integrals please?
Spoiler:
[math]\frac{\int_0^1p^{a+1}(1-p)^b\mathrm{d}p}{\int_0^1p^a(1-p)^b\mathrm{d}p}[/math]
[math]= \frac{\int_0^1p^{3+1}(1-p)^1\mathrm{d}p}{\int_0^1p^3(1-p)^1\mathrm{d}p}[/math]
[math]= \frac{\int_0^1(p^4 - p^5)\mathrm{d}p}{\int_0^1(p^3 - p^4)\mathrm{d}p}[/math]
[math]= \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}[/math]
[math]= \frac{\frac{1}{5} - \frac{1}{6}}{\frac{1}{4} - \frac{1}{5}}[/math]
[math]= \frac{2}{3}[/math]

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

Re: The Mysterious Coin

Postby tomtom2357 » Fri Jan 06, 2012 4:48 am UTC

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

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

Re: The Mysterious Coin

Postby phlip » Fri Jan 06, 2012 5:30 am UTC

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

Postby tomtom2357 » Fri Jan 06, 2012 7:44 am UTC

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

Postby mfb » Fri Jan 06, 2012 12:00 pm UTC

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

Postby tomtom2357 » Fri Jan 06, 2012 12:05 pm UTC

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.

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

Re: The Mysterious Coin

Postby gmalivuk » Fri Jan 06, 2012 1:01 pm UTC

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

Postby tomtom2357 » Fri Jan 06, 2012 2:06 pm UTC

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.

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

Re: The Mysterious Coin

Postby gmalivuk » Fri Jan 06, 2012 2:47 pm UTC

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)

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

Re: The Mysterious Coin

Postby Dason » Fri Jan 06, 2012 6:06 pm UTC

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;

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

Re: The Mysterious Coin

Postby Macbi » Mon Jan 09, 2012 10:35 am UTC

    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

Postby tomtom2357 » Fri Jan 13, 2012 9:06 am UTC

I think that macbi just killed the thread. :D
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

Postby tomtom2357 » Tue Jan 24, 2012 11:06 am UTC

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.

User avatar
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

Postby jestingrabbit » Tue Jan 24, 2012 11:11 am UTC

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


Its right there in the wikipedia article. Read it, and read your private messages by accessing your user control panel, linked towards the top of the page.
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

Postby ybot968 » Fri Sep 18, 2015 4:55 am UTC

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?


Return to “Logic Puzzles”

Who is online

Users browsing this forum: No registered users and 4 guests